Commit 4802cf0c authored by Romain Courteaud's avatar Romain Courteaud

Change TargetSolver API.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3145 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bc79f469
...@@ -46,11 +46,10 @@ class TargetSolver: ...@@ -46,11 +46,10 @@ class TargetSolver:
to update parent target to update parent target
""" """
def __init__(self, simulation_tool, **kw): def __init__(self, **kw):
""" """
Creates an instance of TargetSolver with parameters Creates an instance of TargetSolver with parameters
""" """
self.simulation_tool = simulation_tool
self.__dict__.update(kw) self.__dict__.update(kw)
self.previous_target = {} self.previous_target = {}
...@@ -59,9 +58,10 @@ class TargetSolver: ...@@ -59,9 +58,10 @@ class TargetSolver:
# Saves ONCE ONLY the previous target of a given movement # Saves ONCE ONLY the previous target of a given movement
uid = movement.getUid() uid = movement.getUid()
if not self.previous_target.has_key(uid): if not self.previous_target.has_key(uid):
self.previous_target[uid] = Target(target_quantity = movement.getTargetQuantity(), self.previous_target[uid] = Target(
target_start_date = movement.getTargetStartDate(), target_quantity = movement.getTargetQuantity(),
target_stop_date = movement.getTargetStopDate()) target_start_date = movement.getTargetStartDate(),
target_stop_date = movement.getTargetStopDate())
def getPreviousTarget(self, movement): def getPreviousTarget(self, movement):
# Returns the previous target for a given movement # Returns the previous target for a given movement
...@@ -69,7 +69,7 @@ class TargetSolver: ...@@ -69,7 +69,7 @@ class TargetSolver:
self.savePreviousTarget(movement) self.savePreviousTarget(movement)
return self.previous_target[movement.getUid()] return self.previous_target[movement.getUid()]
def solve(self, movement, new_target): def solve(self, simulation_movement):
""" """
Solve a simulation movement Solve a simulation movement
...@@ -85,6 +85,12 @@ class TargetSolver: ...@@ -85,6 +85,12 @@ class TargetSolver:
""" """
Called in case it is needed for the solving process Called in case it is needed for the solving process
""" """
# Then apply to all movements
for movement in delivery.getMovementList():
simulation_movement_list = movement.getDeliveryRelatedValueList(
portal_type="Simulation Movement")
for simulation_movement in simulation_movement_list:
self.solve(simulation_movement)
def close(self): def close(self):
""" """
...@@ -92,5 +98,7 @@ class TargetSolver: ...@@ -92,5 +98,7 @@ class TargetSolver:
may do some extra steps, such as create a new delivery may do some extra steps, such as create a new delivery
with deliverable split movements. with deliverable split movements.
""" """
# XXX this is not the job of TargetSolver to create new Delivery !
pass
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