From 8210256c4fcf9e3167eeaa7ab80a94ba113f545d Mon Sep 17 00:00:00 2001
From: Leonardo Rochael Almeida <leonardo@nexedi.com>
Date: Thu, 24 Mar 2011 16:18:41 +0000
Subject: [PATCH] Fix AdoptSolver. A movement could have more than one related
 Simulation Movement, and the one returned by getDeliveryRelatedValue() might
 not be the one that is divergent. It could be not even a Simulation Movement
 at all!

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

diff --git a/product/ERP5/Document/AdoptSolver.py b/product/ERP5/Document/AdoptSolver.py
index 6470caf1e3..0b4c1f3483 100644
--- a/product/ERP5/Document/AdoptSolver.py
+++ b/product/ERP5/Document/AdoptSolver.py
@@ -95,9 +95,18 @@ class AdoptSolver(SolverMixin, ConfigurableMixin, XMLObject):
         else:
           # XXX TODO we need to support multiple values for categories or
           # list type property.
-          simulation_movement = movement.getDeliveryRelatedValue()
-          movement.setProperty(solved_property,
-                               simulation_movement.getProperty(solved_property))
+
+          # XXX-Leo: If there is more than one simulation_movement in
+          # the simulation_movement_list, this indicates a wrong
+          # configuration or bad selection by the user. Should we do
+          # anything about it, like log or fail?
+          # Also, the behaviour below is naive, and could cause another
+          # non-divergent Simulation Movement to become divergent.
+          for simulation_movement in simulation_movement_list:
+            movement.setProperty(
+              solved_property,
+              simulation_movement.getProperty(solved_property)
+            )
     # Finish solving
     if self.getPortalObject().portal_workflow.isTransitionPossible(
       self, 'succeed'):
-- 
2.30.9