From 99b1483adf631b9d03deca98d53cb475eafa373c Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Fri, 25 Jun 2010 10:16:45 +0000
Subject: [PATCH] revert changes to fallback to a naive and slow but safe
 implementation of isBuildable

This commit alone represents a performance drop by 300% (3 times slower),
and is kept only to track changes.
The next 5 commits will improve performance, leading to an
overall 500% improvement (5 times faster than before this commit)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36583 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/BusinessPath.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/product/ERP5/Document/BusinessPath.py b/product/ERP5/Document/BusinessPath.py
index a1c5f12522..5aacff7117 100644
--- a/product/ERP5/Document/BusinessPath.py
+++ b/product/ERP5/Document/BusinessPath.py
@@ -382,17 +382,20 @@ class BusinessPath(Path, Predicate):
       delivery_uid=[x.getUid() for x in explanation.getMovementList()])
 
     for simulation_movement in delivery_simulation_movement_list:
-      applied_rule = simulation_movement.getRootAppliedRule().getPath()
+      applied_rule = simulation_movement.getRootAppliedRule()
       root_applied_rule_set.add(applied_rule)
 
-    simulation_movement_list = portal_catalog(
-      portal_type='Simulation Movement', causality_uid=self.getUid(),
-      path=['%s/%%' % x for x in root_applied_rule_set])
+    simulation_movement_list = []
+    for applied_rule in root_applied_rule_set:
+      simulation_movement_list.extend(self._recurseGetValueList(
+        applied_rule, 'Simulation Movement'))
 
-    return [simulation_movement.getObject() for simulation_movement
+    self_url = self.getRelativeUrl()
+    return [simulation_movement for simulation_movement
           in simulation_movement_list
           # related with explanation
-          if self._isDeliverySimulationMovementRelated(
+          if simulation_movement.getCausality() == self_url and \
+            self._isDeliverySimulationMovementRelated(
               simulation_movement, delivery_simulation_movement_list)]
 
   def getExpectedQuantity(self, explanation, *args, **kwargs):
-- 
2.30.9