[Erp5-report] r41658 jm - in /erp5/trunk/bt5/erp5_simulation_legacy: DocumentTemplateItem/ bt/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Dec 22 14:11:09 CET 2010


Author: jm
Date: Wed Dec 22 14:11:09 2010
New Revision: 41658

URL: http://svn.erp5.org?rev=41658&view=rev
Log:
Fix testLegacyBPMCore

Modified:
    erp5/trunk/bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py
    erp5/trunk/bt5/erp5_simulation_legacy/bt/revision

Modified: erp5/trunk/bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py [utf8] (original)
+++ erp5/trunk/bt5/erp5_simulation_legacy/DocumentTemplateItem/SimulationLegacyPatches.py [utf8] Wed Dec 22 14:11:09 2010
@@ -35,8 +35,54 @@ def patch():
 
   composition._LEGACY_SIMULATION = True
 
+  ## Movement
+
+  from Products.ERP5.Document.Movement import Movement
+
+  def isFrozen(self):
+    """
+    Returns the frozen status of this movement.
+    a movement in stopped, delivered or cancelled states is automatically frozen.
+    If frozen is locally set to '0', we must check for a parent set to '1', in
+    which case, we want the children to be frozen as well.
+
+    BPM evaluation allows to set frozen state list per Business Path.
+    """
+    business_path = self.getCausalityValue(portal_type='Business Path')
+    if business_path is None:
+      # XXX Hardcoded
+      # Maybe, we should use getPortalCurrentInventoryStateList
+      # and another portal method for cancelled (and deleted)
+      #     LOG("Movement, isFrozen", DEBUG, "Hardcoded state list")
+      if self.getSimulationState() in ('stopped', 'delivered', 'cancelled'):
+        return 1
+    else:
+      # conditional BPM enabled frozen state check
+      # BPM dynamic configuration
+      if self.getSimulationState() in business_path.getFrozenStateList():
+        return True
+
+    # manually frozen
+    frozen = self._baseIsFrozen()
+    if frozen == 0:
+      self._baseSetFrozen(None)
+    return frozen or False
+
+  Movement.isFrozen = isFrozen
+
   ## SimulationMovement
 
+  from Products.ERP5.Document.SimulationMovement import SimulationMovement
+  del SimulationMovement.isFrozen
+
+  def isCompleted(self):
+    """Zope publisher docstring. Documentation in ISimulationMovement"""
+    # only available in BPM, so fail totally in case of working without BPM
+    return self.getSimulationState() in self.getCausalityValue(
+        portal_type='Business Path').getCompletedStateList()
+
+  SimulationMovement.isCompleted = isCompleted
+
   def asComposedDocument(self, *args, **kw):
     # XXX: What delivery should be used to find amount generator lines ?
     #      With the currently enabled code, entire branches in the simulation
@@ -57,7 +103,22 @@ def patch():
         return self.getOrderValue().asComposedDocument(*args, **kw)
       self = grand_parent
 
-  from Products.ERP5.Document.SimulationMovement import SimulationMovement
   SimulationMovement.asComposedDocument = asComposedDocument
 
+  def isBuildable(self):
+    """Simulation Movement buildable logic"""
+    if self.getDeliveryValue() is not None:
+      # already delivered
+      return False
+
+    # might be buildable - business path dependent
+    business_path = self.getCausalityValue(portal_type='Business Path')
+    explanation_value = self.getExplanationValue()
+    if business_path is None or explanation_value is None:
+      return True
+
+    return len(business_path.filterBuildableMovementList([self])) == 1
+
+  SimulationMovement.isBuildable = isBuildable
+
 patch()

Modified: erp5/trunk/bt5/erp5_simulation_legacy/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_simulation_legacy/bt/revision?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_simulation_legacy/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_simulation_legacy/bt/revision [utf8] Wed Dec 22 14:11:09 2010
@@ -1 +1 @@
-7
\ No newline at end of file
+8
\ No newline at end of file



More information about the Erp5-report mailing list