[Erp5-report] r28063 - /erp5/trunk/products/ERP5/Document/BusinessPath.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jul 13 14:34:59 CEST 2009


Author: luke
Date: Mon Jul 13 14:34:58 2009
New Revision: 28063

URL: http://svn.erp5.org?rev=28063&view=rev
Log:
 - better naming (avoid abbreviation) in internal method
 - fetching simulation movement list made per-explanation, as explanations can be related in different way

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

Modified: erp5/trunk/products/ERP5/Document/BusinessPath.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessPath.py?rev=28063&r1=28062&r2=28063&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessPath.py [utf8] Mon Jul 13 14:34:58 2009
@@ -203,15 +203,12 @@
     """
 
   def _getExplanationUidList(self, explanation):
-    """Helper method to fetch really explanation related movements
-
-       As Business Path is related to movement by causality, thanks to
-       trade_phase during expand, it is correct to pass too much explanations
-       than not enough"""
+    """Helper method to fetch really explanation related movements"""
     explanation_uid_list = [explanation.getUid()]
-    for ex in explanation.getCausalityRelatedValueList(
+    for found_explanation in explanation.getCausalityRelatedValueList(
         portal_type=self.getPortalDeliveryTypeList()):
-      explanation_uid_list.extend(self._getExplanationUidList(ex))
+      explanation_uid_list.extend(self._getExplanationUidList(
+        found_explanation))
     return explanation_uid_list
 
   def build(self, explanation):
@@ -232,12 +229,19 @@
     """
       Returns all Simulation Movements related to explanation
     """
-    # XXX What about explanations for causality related documents to explanation?
-    explanation_uid_list = self._getExplanationUidList(explanation)
-    # getCausalityRelated do not support filtering, so post filtering needed
-    return [x for x in self.getCausalityRelatedValueList(
-      portal_type='Simulation Movement')
-      if x.getExplanationUid() in explanation_uid_list]
+    simulation_movement_value_list = []
+    # first simulation movements related to explanation itself by its applied rule
+    for applied_rule in explanation.getCausalityRelatedValueList(
+        portal_type='Applied Rule'):
+      simulation_movement_value_list.extend([x.getObject() for x in
+        applied_rule.contentValues() if x.getCausalityValue() == self])
+    # now simulation movements which were used to build this delivery
+    for movement in explanation.getMovementList():
+      simulation_movement_value_list.extend([x.getObject() for x in
+        movement.getDeliveryRelatedValueList(
+          portal_type='Simulation Movement') if x \
+              .getCausalityValue() == self])
+      return simulation_movement_value_list
 
   # IBusinessCompletable implementation
   def isCompleted(self, explanation):




More information about the Erp5-report mailing list