Really unlink simulation expansion from Business Process

Don't even search for future trade phases.
parent fc873925
...@@ -284,66 +284,15 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -284,66 +284,15 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
tv[key] = None # disallow further calls to 'calculate' tv[key] = None # disallow further calls to 'calculate'
transaction.get().addBeforeCommitHook(before_commit) transaction.get().addBeforeCommitHook(before_commit)
security.declarePrivate('_getSuccessorTradePhaseList')
def _getSuccessorTradePhaseList(self):
"""
Get the list of future trade_phase categories from this simulation
movement according to the related business process
"""
# XXX-Leo this method could be smaller if (one or more of):
# * Simulation Movements had trade_state instead of trade_phase categories,
# * .asComposedDocument() also included the causality Business Link,
# * BusinessLink objects had a '.getSucessorTradePhaseList' method (accepting
# a context parameter for predicate checking).
# * .getBusinessLinkValueList() accepted a predecessor_link parameter,
# * some of the work below was done by a Business Process method,
portal = self.getPortalObject()
business_process = self.asComposedDocument()
business_link_type_list = portal.getPortalBusinessLinkTypeList()
business_link = self.getCausalityValue(portal_type=business_link_type_list)
if business_link is None:
# XXX-Leo we could just return self.getTradePhaseList() for
# backward compatibility
from Products.ERP5Type.Errors import SimulationError
raise SimulationError('No Business Link Causality for %r. Cannot enumerate successor trade_phases.' %
(self,))
# from this Business Process, get the Business Links which
# predecessor state match the successor state of our Business Link
# causality
successor_trade_state = business_link.getSuccessor()
successor_link_list = business_process.getBusinessLinkValueList(
context=self,
predecessor=successor_trade_state)
successor_trade_phase_list = [link.getTradePhase()
for link in successor_link_list]
return successor_trade_phase_list
security.declarePrivate('_asSuccessorContext')
def _asSuccessorContext(self):
""" Returns a version of self with future trade phases
"""
successor_trade_phase_list = self._getSuccessorTradePhaseList()
context = self.asContext()
context.edit(trade_phase_list=successor_trade_phase_list)
return context
security.declarePrivate('_getApplicableRuleList') security.declarePrivate('_getApplicableRuleList')
def _getApplicableRuleList(self): def _getApplicableRuleList(self):
""" Search rules that match this movement """ Search rules that match this movement
""" """
successor_trade_phase_list = self._getSuccessorTradePhaseList()
portal_rules = self.getPortalObject().portal_rules portal_rules = self.getPortalObject().portal_rules
# XXX-Leo: According to JP, the 'version' search below is wrong and # XXX-Leo: According to JP, the 'version' search below is wrong and
# should be replaced by a check that there are not two rules with the # should be replaced by a check that there are not two rules with the
# same reference that can be returned. # same reference that can be returned.
return portal_rules.searchRuleList( return portal_rules.searchRuleList(self,
self,
# XXX-Leo: Fugly catalog syntax for category search. We should
# fix the catalog to accept just 'trade_phase' for the keyword,
# and not to require prefixing the values with 'trade_phase/' again:
trade_phase_relative_url=['trade_phase/' + path
for path in successor_trade_phase_list],
sort_on='version', sort_on='version',
sort_order='descending') sort_order='descending')
......
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