Commit 44a2fea9 authored by Sebastien Robin's avatar Sebastien Robin

do not assume that the previous date is always defined, I have some case where it is not true


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4529 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7eb1f851
...@@ -50,7 +50,11 @@ class CopyToTarget(TargetSolver): ...@@ -50,7 +50,11 @@ class CopyToTarget(TargetSolver):
new_stop_date = movement.getDeliveryStopDateList()[0] new_stop_date = movement.getDeliveryStopDateList()[0]
# Calculate delta # Calculate delta
quantity_ratio = new_quantity / old_quantity quantity_ratio = new_quantity / old_quantity
start_date_delta = 0
stop_date_delta = 0
if new_start_date is not None and old_start_date is not None:
start_date_delta = new_start_date - old_start_date start_date_delta = new_start_date - old_start_date
if new_stop_date is not None and old_stop_date is not None:
stop_date_delta = new_stop_date - old_stop_date stop_date_delta = new_stop_date - old_stop_date
# Modify recursively simulation movement # Modify recursively simulation movement
self._recursivelySolve(movement, quantity_ratio=quantity_ratio, self._recursivelySolve(movement, quantity_ratio=quantity_ratio,
...@@ -64,10 +68,16 @@ class CopyToTarget(TargetSolver): ...@@ -64,10 +68,16 @@ class CopyToTarget(TargetSolver):
movement. movement.
""" """
# Modify quantity, start_date, stop_date # Modify quantity, start_date, stop_date
start_date = movement.getStartDate()
if start_date is not None:
start_date = start_date + start_date_delta
stop_date = movement.getStopDate()
if stop_date is not None:
stop_date = stop_date + stop_date_delta
movement.edit( movement.edit(
quantity=movement.getQuantity() * quantity_ratio, quantity=movement.getQuantity() * quantity_ratio,
start_date=movement.getStartDate() + start_date_delta, start_date=start_date,
stop_date=movement.getStopDate() + stop_date_delta, stop_date=stop_date
) )
applied_rule = movement.getParent() applied_rule = movement.getParent()
parent_movement = applied_rule.getParent() parent_movement = applied_rule.getParent()
......
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