diff --git a/product/ERP5/Document/BusinessPath.py b/product/ERP5/Document/BusinessPath.py index ca42e3c96313f2b6c424826e1d39f3e3882b18fe..af02406bd5003f5bc6f220ea5eed68a5c1f77cef 100644 --- a/product/ERP5/Document/BusinessPath.py +++ b/product/ERP5/Document/BusinessPath.py @@ -33,7 +33,6 @@ from AccessControl import ClassSecurityInfo from Products.CMFCore.PortalFolder import ContentFilter from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5.Document.Path import Path -from Products.ERP5.Document.BusinessProcess import BackTrack import zope.interface @@ -265,8 +264,9 @@ class BusinessPath(Path): if self.getParentValue().isStartDateReferential(): return explanation.getStartDate() else: - return self.getExpectedStopDate(explanation, *args, **kwargs)\ - - self.getLeadTime() + expected_date = self.getExpectedStopDate(explanation, *args, **kwargs) + if expected_date is not None: + return expected_date - self.getLeadTime() def _getPredecessorExpectedStartDate(self, explanation, predecessor_date=None, *args, **kwargs): if predecessor_date is None: @@ -279,8 +279,9 @@ class BusinessPath(Path): def _getSuccessorExpectedStartDate(self, explanation, *args, **kwargs): node = self.getSuccessorValue() if node is not None: - return node.getExpectedBeginningDate(explanation, *args, **kwargs)\ - - self.getLeadTime() + expected_date = node.getExpectedBeginningDate(explanation, *args, **kwargs) + if expected_date is not None: + return expected_date - self.getLeadTime() def getExpectedStopDate(self, explanation, predecessor_date=None, *args, **kwargs): """ @@ -301,14 +302,16 @@ class BusinessPath(Path): if self.getParentValue().isStopDateReferential(): return explanation.getStopDate() else: - return self.getExpectedStartDate(explanation, *args, **kwargs)\ - + self.getLeadTime() + expected_date = self.getExpectedStartDate(explanation, *args, **kwargs) + if expected_date is not None: + return expected_date + self.getLeadTime() def _getPredecessorExpectedStopDate(self, explanation, *args, **kwargs): node = self.getPredecessorValue() if node is not None: - return node.getExpectedCompletionDate(explanation, *args, **kwargs)\ - + self.getWaitTime() + self.getLeadTime() + expected_date = node.getExpectedCompletionDate(explanation, *args, **kwargs) + if expected_date is not None: + return expected_date + self.getWaitTime() + self.getLeadTime() def _getSuccessorExpectedStopDate(self, explanation, *args, **kwargs): node = self.getSuccessorValue() @@ -338,19 +341,11 @@ class BusinessPath(Path): return root_explanation_method( explanation, visited=visited, *args, **kwargs) - predecessor_expected_date = None - try: - predecessor_expected_date = predecessor_method( - explanation, visited=visited, *args, **kwargs) - except BackTrack: - pass + predecessor_expected_date = predecessor_method( + explanation, visited=visited, *args, **kwargs) - successor_expected_date = None - try: - successor_expected_date = successor_method( - explanation, visited=visited, *args, **kwargs) - except BackTrack: - pass + successor_expected_date = successor_method( + explanation, visited=visited, *args, **kwargs) if successor_expected_date is not None or \ predecessor_expected_date is not None: diff --git a/product/ERP5/Document/BusinessProcess.py b/product/ERP5/Document/BusinessProcess.py index e04830d076dd13f2dd576d1f46b74ba2fd092d44..86d75d3d6c32c2649dd9bd5fe528aaf718c1718f 100644 --- a/product/ERP5/Document/BusinessProcess.py +++ b/product/ERP5/Document/BusinessProcess.py @@ -34,12 +34,6 @@ from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5.Document.Path import Path -class BackTrack(Exception): - # XXX this defined here until refactor - """ - This is a utility Exception for tree back tracking. - """ - class BusinessProcess(Path, XMLObject): """ The BusinessProcess class is a container class which is used diff --git a/product/ERP5/Document/BusinessState.py b/product/ERP5/Document/BusinessState.py index fd89d3406162c184c9ccd4cc5c72e68664c8789a..ee6e176cc98c780d2b464e0431330d28ef45e111 100644 --- a/product/ERP5/Document/BusinessState.py +++ b/product/ERP5/Document/BusinessState.py @@ -32,7 +32,6 @@ from AccessControl import ClassSecurityInfo from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type.XMLObject import XMLObject -from Products.ERP5.Document.BusinessProcess import BackTrack class BusinessState(XMLObject): """ @@ -89,11 +88,13 @@ class BusinessState(XMLObject): # Should be re-calculated? if 'predecessor_date' in kwargs: del kwargs['predecessor_date'] - return min(self._getExpectedDateList(explanation, - self.getSuccessorRelatedValueList(), - self._getExpectedCompletionDate, - *args, - **kwargs)) + date_list = self._getExpectedDateList(explanation, + self.getSuccessorRelatedValueList(), + self._getExpectedCompletionDate, + *args, + **kwargs) + if len(date_list) > 0: + return min(date_list) def _getExpectedCompletionDate(self, path, *args, **kwargs): return path.getExpectedStopDate(*args, **kwargs) @@ -108,11 +109,13 @@ class BusinessState(XMLObject): # Should be re-calculated? if 'predecessor_date' in kwargs: del kwargs['predecessor_date'] - return min(self._getExpectedDateList(explanation, - self.getPredecessorRelatedValueList(), - self._getExpectedBeginningDate, - *args, - **kwargs)) + date_list = self._getExpectedDateList(explanation, + self.getPredecessorRelatedValueList(), + self._getExpectedBeginningDate, + *args, + **kwargs) + if len(date_list) > 0: + return min(date_list) def _getExpectedBeginningDate(self, path, *args, **kwargs): expected_date = path.getExpectedStartDate(*args, **kwargs) @@ -141,11 +144,7 @@ class BusinessState(XMLObject): if expected_date is not None: expected_date_list.append(expected_date) - # if visiting leaf of tree - if len(expected_date_list) == 0: - raise BackTrack - else: - return expected_date_list + return expected_date_list def getExpectedCompletionDuration(self, explanation): """