Commit 3d9a9177 authored by Tatuya Kamada's avatar Tatuya Kamada

Make Business Path work as a Predicate, and use the predicate API to select...

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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34031 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 314ede2d
......@@ -33,10 +33,11 @@ from AccessControl import ClassSecurityInfo
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 @@ class BusinessPath(Path):
interfaces.IArrowBase,
interfaces.IBusinessPath,
interfaces.IBusinessBuildable,
interfaces.IBusinessCompletable
interfaces.IBusinessCompletable,
interfaces.IPredicate,
)
# IArrowBase implementation
......@@ -367,6 +369,17 @@ class BusinessPath(Path):
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')
......
......@@ -92,7 +92,8 @@ class BusinessProcess(Path, XMLObject):
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
......
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