[Erp5-report] r36766 kazuhiko - in /erp5/trunk/products/ERP5: DeliverySolver/ Document/ int...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jul 1 11:51:11 CEST 2010


Author: kazuhiko
Date: Thu Jul  1 11:51:10 2010
New Revision: 36766

URL: http://svn.erp5.org?rev=36766&view=rev
Log:
propagate activity parameters in whole solver processes.

Modified:
    erp5/trunk/products/ERP5/DeliverySolver/FIFO.py
    erp5/trunk/products/ERP5/DeliverySolver/MinPrice.py
    erp5/trunk/products/ERP5/Document/AcceptSolver.py
    erp5/trunk/products/ERP5/Document/AdoptSolver.py
    erp5/trunk/products/ERP5/Document/QuantitySplitSolver.py
    erp5/trunk/products/ERP5/Document/SolverProcess.py
    erp5/trunk/products/ERP5/Document/TradeModelSolver.py
    erp5/trunk/products/ERP5/Document/UnifySolver.py
    erp5/trunk/products/ERP5/interfaces/solver.py

Modified: erp5/trunk/products/ERP5/DeliverySolver/FIFO.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/DeliverySolver/FIFO.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/DeliverySolver/FIFO.py [utf8] (original)
+++ erp5/trunk/products/ERP5/DeliverySolver/FIFO.py [utf8] Thu Jul  1 11:51:10 2010
@@ -58,7 +58,7 @@ class FIFO(DeliverySolver):
       total_quantity += movement.getQuantity()
     return total_quantity
 
-  def setTotalQuantity(self, new_quantity):
+  def setTotalQuantity(self, new_quantity, activate_kw=None):
     """
     """
     result = []
@@ -72,14 +72,15 @@ class FIFO(DeliverySolver):
         if quantity < remaining_quantity:
           result.append((movement, quantity))
           remaining_quantity -= quantity
-          movement.setQuantity(0)
+          movement.edit(quantity=0, delivery_ratio=0, activate_kw=activate_kw)
         else:
           result.append((movement, remaining_quantity))
-          movement.setQuantity(quantity - remaining_quantity)
+          movement_quantity = quantity - remaining_quantity
+          movement.edit(quantity=movement_quantity,
+                        delivery_ratio=movement_quantity / new_quantity,
+                        activate_kw=activate_kw)
           remaining_quantity = 0
     # Return movement, split_quantity tuples
-    for movement in simulation_movement_list:
-      movement.setDeliveryRatio(movement.getQuantity() / new_quantity)
     return result
 
   def _getSimulationMovementList(self):

Modified: erp5/trunk/products/ERP5/DeliverySolver/MinPrice.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/DeliverySolver/MinPrice.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/DeliverySolver/MinPrice.py [utf8] (original)
+++ erp5/trunk/products/ERP5/DeliverySolver/MinPrice.py [utf8] Thu Jul  1 11:51:10 2010
@@ -42,7 +42,7 @@ class MinPrice(FIFO):
 
   title = 'MinPrice Solver'
 
-  def setTotalQuantity(self, new_quantity):
+  def setTotalQuantity(self, new_quantity, activate_kw=None):
     """
     """
     result = []
@@ -58,14 +58,15 @@ class MinPrice(FIFO):
         if quantity < remaining_quantity:
           result.append((movement, quantity))
           remaining_quantity -= quantity
-          movement.setQuantity(0)
+          movement.edit(quantity=0, delivery_ratio=0, activate_kw=activate_kw)
         else:
           result.append((movement, remaining_quantity))
-          movement.setQuantity(quantity - remaining_quantity)
+          movement_quantity = quantity - remaining_quantity
+          movement.edit(quantity=movement_quantity,
+                        delivery_ratio=movement_quantity / new_quantity,
+                        activate_kw=activate_kw)
           remaining_quantity = 0
     # Return movement, split_quantity tuples
-    for movement in simulation_movement_list:
-      movement.setDeliveryRatio(movement.getQuantity() / new_quantity)
     return result
 
   def _getSimulationMovementList(self):

Modified: erp5/trunk/products/ERP5/Document/AcceptSolver.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AcceptSolver.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AcceptSolver.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AcceptSolver.py [utf8] Thu Jul  1 11:51:10 2010
@@ -58,7 +58,7 @@ class AcceptSolver(SolverMixin, Configur
   zope.interface.implements(interfaces.ISolver,)
 
   # ISolver Implementation
-  def solve(self):
+  def solve(self, activate_kw=None):
     """
     Adopt new property to simulation movements, with keeping the
     original one recorded.
@@ -69,6 +69,9 @@ class AcceptSolver(SolverMixin, Configur
       portal_type = self.getPortalObject().portal_types.getTypeInfo(self)
       solved_property_list = portal_type.getTestedPropertyList()
     for simulation_movement in self.getDeliveryValueList():
+      if activate_kw is not None:
+        simulation_movement.setDefaultActivateParameters(
+        activate_kw=activate_kw, **activate_kw)
       movement = simulation_movement.getDeliveryValue()
       value_dict = {}
       for solved_property in solved_property_list:
@@ -83,6 +86,6 @@ class AcceptSolver(SolverMixin, Configur
         if not simulation_movement.isPropertyRecorded(property_id):
           simulation_movement.recordProperty(property_id)
         simulation_movement.setMappedProperty(property_id, value)
-      simulation_movement.expand()
+      simulation_movement.expand(activate_kw=activate_kw)
     # Finish solving
     self.succeed()

Modified: erp5/trunk/products/ERP5/Document/AdoptSolver.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AdoptSolver.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AdoptSolver.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AdoptSolver.py [utf8] Thu Jul  1 11:51:10 2010
@@ -60,7 +60,7 @@ class AdoptSolver(SolverMixin, Configura
                            )
 
   # ISolver Implementation
-  def solve(self):
+  def solve(self, activate_kw=None):
     """
     Adopt new property to movements or deliveries.
     """
@@ -73,6 +73,9 @@ class AdoptSolver(SolverMixin, Configura
       delivery_dict.setdefault(simulation_movement.getDeliveryValue(),
                                []).append(simulation_movement)
     for movement, simulation_movement_list in delivery_dict.iteritems():
+      if activate_kw is not None:
+        movement.setDefaultActivateParameters(
+          activate_kw=activate_kw, **activate_kw)
       for solved_property in solved_property_list:
         # XXX hardcoded
         if solved_property == 'quantity':
@@ -84,7 +87,8 @@ class AdoptSolver(SolverMixin, Configura
             delivery_ratio = quantity / total_quantity
             delivery_error = total_quantity * delivery_ratio - quantity
             simulation_movement.edit(delivery_ratio=delivery_ratio,
-                                     delivery_error=delivery_error)
+                                     delivery_error=delivery_error,
+                                     activate_kw=activate_kw)
         else:
           # XXX TODO we need to support multiple values for categories or
           # list type property.

Modified: erp5/trunk/products/ERP5/Document/QuantitySplitSolver.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/QuantitySplitSolver.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/QuantitySplitSolver.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/QuantitySplitSolver.py [utf8] Thu Jul  1 11:51:10 2010
@@ -63,7 +63,7 @@ class QuantitySplitSolver(SolverMixin, C
                            )
 
   # ISolver Implementation
-  def solve(self):
+  def solve(self, activate_kw=None):
     """
     """
     configuration_dict = self.getConfigurationPropertyDict()
@@ -76,7 +76,8 @@ class QuantitySplitSolver(SolverMixin, C
       delivery_solver = self.portal_solvers.newDeliverySolver(
         configuration_dict['delivery_solver'], simulation_movement_list)
       # Update the quantity using delivery solver algorithm
-      split_list = delivery_solver.setTotalQuantity(decision_quantity)
+      split_list = delivery_solver.setTotalQuantity(decision_quantity,
+                                                    activate_kw=activate_kw)
       # Create split movements
       for (simulation_movement, split_quantity) in split_list:
         split_index = 0
@@ -91,7 +92,10 @@ class QuantitySplitSolver(SolverMixin, C
                    'id':new_id,
                    'delivery':None,
                    'quantity':split_quantity})
-        new_movement = applied_rule.newContent(**kw)
+        new_movement = applied_rule.newContent(activate_kw=activate_kw, **kw)
+        if activate_kw is not None:
+          new_movement.setDefaultActivateParameters(
+            activate_kw=activate_kw, **activate_kw)
         start_date = configuration_dict.get('start_date', None)
         if start_date is not None:
           new_movement.recordProperty('start_date')
@@ -100,6 +104,9 @@ class QuantitySplitSolver(SolverMixin, C
         if stop_date is not None:
           new_movement.recordProperty('stop_date')
           new_movement.setStopDate(stop_date)
+        # XXX we need to call expand on both simulation_movement and new_movement here?
+        # simulation_movement.expand(activate_kw=activate_kw)
+        # new_movement.expand(activate_kw=activate_kw)
 
     # Finish solving
     self.succeed()

Modified: erp5/trunk/products/ERP5/Document/SolverProcess.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/SolverProcess.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/SolverProcess.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/SolverProcess.py [utf8] Thu Jul  1 11:51:10 2010
@@ -173,7 +173,7 @@ class SolverProcess(XMLObject, ActivePro
   # ISolver implementation
   # Solver Process Workflow Interface
   #  NOTE: how can we consider that a workflow defines or provides an interface ?
-  def solve(self):
+  def solve(self, activate_kw=None):
     """
       Start solving
     """
@@ -181,7 +181,8 @@ class SolverProcess(XMLObject, ActivePro
     for solver in self.contentValues(portal_type=self.getPortalObject().getPortalTargetSolverTypeList()):
       if isTransitionPossible(solver, 'start_solving'):
         solver.startSolving()
-        solver.activate(active_process=self).solve()
+        solver.activate(active_process=self, activate_kw=activate_kw).solve(
+          activate_kw=activate_kw)
 
   # API
   def isSolverDecisionListConsistent(self):

Modified: erp5/trunk/products/ERP5/Document/TradeModelSolver.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TradeModelSolver.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TradeModelSolver.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TradeModelSolver.py [utf8] Thu Jul  1 11:51:10 2010
@@ -55,7 +55,7 @@ class TradeModelSolver(AcceptSolver):
   zope.interface.implements(interfaces.ISolver,)
 
   # ISolver Implementation
-  def solve(self):
+  def solve(self, activate_kw=None):
     """
     Adopt new values to simulation movements, with keeping the original
     one recorded, and then update Trade Model related lines accordingly.
@@ -93,6 +93,9 @@ class TradeModelSolver(AcceptSolver):
     # then expand.
     for movement, simulation_movement_list in delivery_dict.iteritems():
       for simulation_movement in simulation_movement_list:
+        if activate_kw is not None:
+          simulation_movement.setDefaultActivateParameters(
+            activate_kw=activate_kw, **activate_kw)
         value_dict = {}
         for solved_property in solved_property_list:
           new_value = movement.getProperty(solved_property)
@@ -104,12 +107,16 @@ class TradeModelSolver(AcceptSolver):
         for property_id, value in value_dict.iteritems():
           if not simulation_movement.isPropertyRecorded(property_id):
             simulation_movement.recordProperty(property_id)
-          simulation_movement.setMappedProperty(property_id, value)
-        simulation_movement.expand()
+          simulation_movement.setMappedProperty(property_id, value,
+                                                activate_kw=activate_kw)
+        simulation_movement.expand(activate_kw=activate_kw)
 
     # Third, adopt changes on trade model related lines.
     # XXX non-linear case is not yet supported.
     for movement in trade_model_related_movement_list:
+      if activate_kw is not None:
+        movement.setDefaultActivateParameters(
+          activate_kw=activate_kw, **activate_kw)
       for solved_property in solved_property_list:
         if solved_property == 'quantity':
           simulation_movement_list = movement.getDeliveryRelatedValueList()
@@ -121,7 +128,8 @@ class TradeModelSolver(AcceptSolver):
             delivery_ratio = quantity / total_quantity
             delivery_error = total_quantity * delivery_ratio - quantity
             simulation_movement.edit(delivery_ratio=delivery_ratio,
-                                     delivery_error=delivery_error)
+                                     delivery_error=delivery_error,
+                                     activate_kw=activate_kw)
         else:
           # XXX TODO we need to support multiple values for categories or
           # list type property.

Modified: erp5/trunk/products/ERP5/Document/UnifySolver.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/UnifySolver.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/UnifySolver.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/UnifySolver.py [utf8] Thu Jul  1 11:51:10 2010
@@ -56,7 +56,7 @@ class UnifySolver(AcceptSolver):
   zope.interface.implements(interfaces.ISolver,)
 
   # ISolver Implementation
-  def solve(self):
+  def solve(self, activate_kw=None):
     """
     Adopt new property to simulation movements, with keeping the
     original one recorded.
@@ -72,15 +72,21 @@ class UnifySolver(AcceptSolver):
       delivery_dict.setdefault(simulation_movement.getDeliveryValue(),
                                []).append(simulation_movement)
     for movement, simulation_movement_list in delivery_dict.iteritems():
+      if activate_kw is not None:
+        movement.setDefaultActivateParameters(
+          activate_kw=activate_kw, **activate_kw)
       configuration_dict = self.getConfigurationPropertyDict()
       new_value = configuration_dict.get('value')
       movement.setProperty(solved_property, new_value)
       for simulation_movement in simulation_movement_list:
+        if activate_kw is not None:
+          simulation_movement.setDefaultActivateParameters(
+            activate_kw=activate_kw, **activate_kw)
         value_dict = {solved_property:new_value}
         for property_id, value in value_dict.iteritems():
           if not simulation_movement.isPropertyRecorded(property_id):
             simulation_movement.recordProperty(property_id)
           simulation_movement.setMappedProperty(property_id, value)
-        simulation_movement.expand()
+        simulation_movement.expand(activate_kw=activate_kw)
     # Finish solving
     self.succeed()

Modified: erp5/trunk/products/ERP5/interfaces/solver.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/interfaces/solver.py?rev=36766&r1=36765&r2=36766&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/interfaces/solver.py [utf8] (original)
+++ erp5/trunk/products/ERP5/interfaces/solver.py [utf8] Thu Jul  1 11:51:10 2010
@@ -46,7 +46,7 @@ class ISolver(Interface):
     - find a way to define at which level to solve divergences
       (ex. line, delivery)
   """
-  def solve():
+  def solve(activate_kw=None):
     """
     Start the solving process (and trigger the workflow method
     in solver_process_workflow). At the end the solving process,




More information about the Erp5-report mailing list