From 739183746dafee5adba939fdbd8473a8898d3cee Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Mon, 7 Jun 2010 20:17:27 +0000 Subject: [PATCH] Extended getCompletionDate to support the case in which the CompletionDate is found on the delivery line, whenever simulation movement has not yet been built (but is it really useful ?) git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@36054 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/BusinessPath.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/product/ERP5/Document/BusinessPath.py b/product/ERP5/Document/BusinessPath.py index 5ef93dc098..568ba4cf6f 100644 --- a/product/ERP5/Document/BusinessPath.py +++ b/product/ERP5/Document/BusinessPath.py @@ -64,6 +64,8 @@ class BusinessPath(Path, Predicate): TODO: - IArrowBase implementation has too many comments which need to be fixed + - _getExplanationRelatedMovementValueList may be superfluous. Make + sure it is really needed """ meta_type = 'ERP5 Business Path' portal_type = 'Business Path' @@ -102,6 +104,10 @@ class BusinessPath(Path, Predicate): explanation_cache = _getExplanationCache(explanation) return explanation_cache.getBusinessPathRelatedSimulationMovementValueList(self) + def _getExplanationRelatedMovementValueList(self, explanation): + explanation_cache = _getExplanationCache(explanation) + return explanation_cache.getBusinessPathRelatedMovementValueList(self) + # IArrowBase implementation security.declareProtected(Permissions.AccessContentsInformation, 'getSourceArrowBaseCategoryList') @@ -256,15 +262,20 @@ class BusinessPath(Path, Predicate): explanation -- the Order, Order Line, Delivery or Delivery Line which implicitely defines a simulation subtree and a union business process. - - NOTE: - It seems that current implementation makes sense mostly in the - context of a root explanation. """ date_list = [] + + # First, let us try to find simulation movements in simulation + # (hoping that it is already built) for movement in self._getExplanationRelatedSimulationMovementValueList(explanation): date_list.append(self.getMovementCompletionDate(movement)) + # Next, try to find delivery lines or cells which may provide + # a good definition of completion date. + if not date_list: + for movement in self._getExplanationRelatedMovementValueList(explanation): + date_list.append(self.getMovementCompletionDate(movement)) + return max(date_list) security.declareProtected(Permissions.AccessContentsInformation, -- 2.30.9