From 747105327833cec6ecba28f0932d02a28a84a4cb Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Wed, 8 Jun 2005 09:52:37 +0000 Subject: [PATCH] Distribute equally ratio to all movements when total quantity is 0. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3213 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/MovementGroup.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/product/ERP5/MovementGroup.py b/product/ERP5/MovementGroup.py index 29ef567fe4..9bf2ae6f8c 100755 --- a/product/ERP5/MovementGroup.py +++ b/product/ERP5/MovementGroup.py @@ -247,6 +247,7 @@ class PathMovementGroup(RootMovementGroup): #LOG('PathGroup.__init__ source_section',0,self.source_section) self.destination_section = movement.getDestinationSection() #LOG('PathGroup.__init__ destination_section',0,self.destination_section) + self.setGroupEdit( source_value=movement.getSourceValue(), destination_value=movement.getDestinationValue(), @@ -254,7 +255,6 @@ class PathMovementGroup(RootMovementGroup): destination_section_value=movement.getDestinationSectionValue(), ) - def test(self,movement): if movement.getSource() == self.source and \ movement.getDestination() == self.destination and \ @@ -312,7 +312,7 @@ class ResourceMovementGroup(RootMovementGroup): RootMovementGroup.__init__(self, movement=movement, **kw) self.resource = movement.getResource() self.setGroupEdit( - resource_value=self.resource + resource_value=movement.getResourceValue() ) def test(self,movement): @@ -475,9 +475,15 @@ class FakeMovement: for movement in self.__movement_list: total_quantity += movement.getQuantity() - for movement in self.__movement_list: - quantity = movement.getQuantity() - movement.setDeliveryRatio(quantity*delivery_ratio/total_quantity) + if total_quantity != 0: + for movement in self.__movement_list: + quantity = movement.getQuantity() + movement.setDeliveryRatio(quantity*delivery_ratio/total_quantity) + else: + # Distribute equally ratio to all movement + mvt_ratio = 1 / len(self.__movement_list) + for movement in self.__movement_list: + movement.setDeliveryRatio(mvt_ratio) def getPrice(self): """ -- 2.30.9