Commit 6f387a63 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_simulation: only modify the first movement to have correct value

parent c3f9b734
......@@ -75,10 +75,19 @@ class QuantityDeliverySolver(XMLObject):
result = []
remaining_quantity = self.getTotalQuantity() - new_quantity
simulation_movement_list = self._getSimulationMovementList()
for movement in simulation_movement_list:
movement.edit(quantity=new_quantity, activate_kw=activate_kw)
if simulation_movement_list:
movement = simulation_movement_list[0]
movement.edit(quantity=movement.getQuantity() + (new_quantity - self.getTotalQuantity()), activate_kw=activate_kw)
if remaining_quantity > 0:
result.append((movement, remaining_quantity))
if new_quantity:
for movement in simulation_movement_list:
movement.edit(delivery_ratio=movement.getQuantity() / new_quantity, activate_kw=activate_kw)
else:
for movement in simulation_movement_list:
movement.edit(delivery_ratio=0, activate_kw=activate_kw)
return result
def _getSimulationMovementList(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment