From 5ba400fc0a66e4a0bcf1b4cb2ec7a30d12800c60 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Wed, 13 Apr 2011 09:39:34 +0000
Subject: [PATCH] * isBuildable was looking at all business link associated  
 to a particular trade phase category, so it was looking   at business link of
 business process not all related to   this particular simulation movement. So
 use   asComposedDocument in order to get good list of business   links * add
 comments about undocumented and untested code

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45361 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/SimulationMovement.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/Document/SimulationMovement.py b/product/ERP5/Document/SimulationMovement.py
index 2736c981da..4a3e56454e 100644
--- a/product/ERP5/Document/SimulationMovement.py
+++ b/product/ERP5/Document/SimulationMovement.py
@@ -666,14 +666,16 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
     ## XXX Code below following line has been moved to BusinessPath (cf r37116)
     #return len(business_path.filterBuildableMovementList([self])) == 1
 
-    predecessor_state = business_link.getPredecessorValue()
+    predecessor_state = business_link.getPredecessor()
     if predecessor_state is None:
       # first one, can be built
       return True # XXX-JPS wrong cause root is marked
 
     # movement is not built, and corresponding business path
     # has predecessors: check movements related to those predecessors!
-    predecessor_path_list = predecessor_state.getSuccessorRelatedValueList()
+    composed_document = self.asComposedDocument()
+    predecessor_link_list = composed_document.getBusinessLinkValueList(
+            successor=predecessor_state)
 
     def isBuiltAndCompleted(simulation, path):
       return simulation.getCausalityValue() is not None and \
@@ -692,7 +694,7 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
       current = current.getParentValue().getParentValue()
 
     remaining_path_set = set()
-    for path in predecessor_path_list:
+    for path in predecessor_link_list:
       related_simulation = causality_dict.get(path.getRelativeUrl())
       if related_simulation is None:
         remaining_path_set.add(path)
@@ -709,6 +711,9 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
     if not remaining_path_set:
       return True
 
+    # XXX(Seb) All the code below is not tested and not documented.
+    # Documentation must be written, the code must be reviewed or dropped
+
     # But sometimes we have to dig deeper
 
     ### Step 2:
-- 
2.30.9