Commit c6dcb51f authored by Jérome Perrin's avatar Jérome Perrin

prevent ZeroDivisionError


git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37473 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ccee0fad
...@@ -84,7 +84,10 @@ class AdoptSolver(SolverMixin, ConfigurableMixin, XMLObject): ...@@ -84,7 +84,10 @@ class AdoptSolver(SolverMixin, ConfigurableMixin, XMLObject):
movement.setQuantity(total_quantity) movement.setQuantity(total_quantity)
for simulation_movement in simulation_movement_list: for simulation_movement in simulation_movement_list:
quantity = simulation_movement.getQuantity() quantity = simulation_movement.getQuantity()
delivery_ratio = quantity / total_quantity if total_quantity == 0:
delivery_ratio = 1.
else:
delivery_ratio = quantity / total_quantity
delivery_error = total_quantity * delivery_ratio - quantity delivery_error = total_quantity * delivery_ratio - quantity
simulation_movement.edit(delivery_ratio=delivery_ratio, simulation_movement.edit(delivery_ratio=delivery_ratio,
delivery_error=delivery_error, delivery_error=delivery_error,
......
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