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

when we create compensation movements to cancel an existing movement we should

not only negate its quantity but also remove the delivery link, otherwise we
create compensation movements which are already built


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44255 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 18fd24c0
...@@ -368,6 +368,7 @@ class RuleMixin(Predicate): ...@@ -368,6 +368,7 @@ class RuleMixin(Predicate):
# Compensate non deletable # Compensate non deletable
new_movement = decision_movement.asContext( new_movement = decision_movement.asContext(
quantity=-decision_movement.getQuantity()) quantity=-decision_movement.getQuantity())
new_movement.setDelivery(None)
movement_collection_diff.addNewMovement(new_movement) movement_collection_diff.addNewMovement(new_movement)
return return
...@@ -412,6 +413,7 @@ class RuleMixin(Predicate): ...@@ -412,6 +413,7 @@ class RuleMixin(Predicate):
if not _compare(profit_tester_list, prevision_movement, decision_movement): if not _compare(profit_tester_list, prevision_movement, decision_movement):
new_movement = decision_movement.asContext( new_movement = decision_movement.asContext(
quantity=-decision_movement_quantity) quantity=-decision_movement_quantity)
new_movement.setDelivery(None)
movement_collection_diff.addNewMovement(new_movement) movement_collection_diff.addNewMovement(new_movement)
compensated_quantity += decision_movement_quantity compensated_quantity += decision_movement_quantity
else: else:
...@@ -436,6 +438,7 @@ class RuleMixin(Predicate): ...@@ -436,6 +438,7 @@ class RuleMixin(Predicate):
if not _compare(divergence_tester_list, prevision_movement, decision_movement): if not _compare(divergence_tester_list, prevision_movement, decision_movement):
new_movement = decision_movement.asContext( new_movement = decision_movement.asContext(
quantity=-decision_movement_quantity) quantity=-decision_movement_quantity)
new_movement.setDelivery(None)
movement_collection_diff.addNewMovement(new_movement) movement_collection_diff.addNewMovement(new_movement)
compensated_quantity += decision_movement_quantity compensated_quantity += decision_movement_quantity
else: else:
...@@ -472,6 +475,7 @@ class RuleMixin(Predicate): ...@@ -472,6 +475,7 @@ class RuleMixin(Predicate):
# It is still possible to add a new movement some movements are not # It is still possible to add a new movement some movements are not
# completed # completed
new_movement = prevision_movement.asContext(quantity=missing_quantity) new_movement = prevision_movement.asContext(quantity=missing_quantity)
new_movement.setDelivery(None)
movement_collection_diff.addNewMovement(new_movement) movement_collection_diff.addNewMovement(new_movement)
elif updatable_compensation_movement is not None: elif updatable_compensation_movement is not None:
# If not, it means that all movements are completed # If not, it means that all movements are completed
......
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