[Erp5-report] r34031 tatuya - /erp5/trunk/products/ERP5/Document/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Mar 24 05:05:00 CET 2010


Author: tatuya
Date: Wed Mar 24 05:04:58 2010
New Revision: 34031

URL: http://svn.erp5.org?rev=34031&view=rev
Log:
Make Business Path work as a Predicate, and use the predicate API to select business paths at Business Process so that we can select appropriate business paths with the API, not only with a trade_phase category.

Modified:
    erp5/trunk/products/ERP5/Document/BusinessPath.py
    erp5/trunk/products/ERP5/Document/BusinessProcess.py

Modified: erp5/trunk/products/ERP5/Document/BusinessPath.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessPath.py?rev=34031&r1=34030&r2=34031&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] Wed Mar 24 05:04:58 2010
@@ -33,10 +33,11 @@
 
 from Products.ERP5Type import Permissions, PropertySheet, interfaces
 from Products.ERP5.Document.Path import Path
+from Products.ERP5.Document.Predicate import Predicate
 
 import zope.interface
 
-class BusinessPath(Path):
+class BusinessPath(Path, Predicate):
   """
     The BusinessPath class embeds all information related to
     lead times and parties involved at a given phase of a business
@@ -88,7 +89,8 @@
                             interfaces.IArrowBase,
                             interfaces.IBusinessPath,
                             interfaces.IBusinessBuildable,
-                            interfaces.IBusinessCompletable
+                            interfaces.IBusinessCompletable,
+                            interfaces.IPredicate,
                             )
 
   # IArrowBase implementation
@@ -367,6 +369,17 @@
         portal_type='Simulation Movement'))
     return movement_list
 
+  # IPredicate implementation
+  security.declareProtected(Permissions.AccessContentsInformation, 'test')
+  def test(self, *args, **kw):
+    """
+    Returns whether the business path is used or not by a given movement context.
+    If test method is not defined in a business path, returns True
+    """
+    if not self.getTestMethodId():
+      return True
+    return Predicate.test(self, *args, **kw)
+
   # IBusinessPath implementation
   security.declareProtected(Permissions.AccessContentsInformation,
       'getRelatedSimulationMovementValueList')

Modified: erp5/trunk/products/ERP5/Document/BusinessProcess.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessProcess.py?rev=34031&r1=34030&r2=34031&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessProcess.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessProcess.py [utf8] Wed Mar 24 05:04:58 2010
@@ -92,7 +92,8 @@
       return business_path_list
     trade_phase = set(trade_phase)
     for document in business_path_list:
-      if trade_phase.intersection(document.getTradePhaseList()):
+      if trade_phase.intersection(document.getTradePhaseList()) and \
+              document.test(context):
         result.append(document)
     return result
 




More information about the Erp5-report mailing list