From e81f1f8f57663f94cc319c90cbe9d29cd74eab74 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Thu, 28 Jan 2010 04:57:43 +0000
Subject: [PATCH] add a missing import.

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

diff --git a/product/ERP5/Document/QuantitySplitSolver.py b/product/ERP5/Document/QuantitySplitSolver.py
index 72b9081255..2723579a4c 100644
--- a/product/ERP5/Document/QuantitySplitSolver.py
+++ b/product/ERP5/Document/QuantitySplitSolver.py
@@ -29,7 +29,7 @@
 
 import zope.interface
 from AccessControl import ClassSecurityInfo
-from Products.CMFCore.utils import getToolByName
+from Acquisition import aq_base
 from Products.ERP5Type import Permissions, PropertySheet, interfaces
 from Products.ERP5Type.XMLObject import XMLObject
 from Products.ERP5.mixin.solver import SolverMixin
@@ -76,12 +76,19 @@ class QuantitySplitSolver(SolverMixin, ConfigurableMixin, XMLObject):
       split_list = delivery_solver.setTotalQuantity(decision_quantity)
       # Create split movements
       for (simulation_movement, split_quantity) in split_list:
+        split_index = 0
+        new_id = "%s_split_%s" % (simulation_movement.getId(), split_index)
+        applied_rule = simulation_movement.getParentValue()
+        while getattr(aq_base(applied_rule), new_id, None) is not None:
+          split_index += 1
+          new_id = "%s_split_%s" % (simulation_movement.getId(), split_index)
         # Copy at same level
         kw = _getPropertyAndCategoryList(simulation_movement)
         kw.update({'portal_type':simulation_movement.getPortalType(),
-                              'delivery':None,
-                              'quantity':split_quantity})
-        new_movement = simulation_movement.getParentValue().newContent(**kw)
+                   'id':new_id,
+                   'delivery':None,
+                   'quantity':split_quantity})
+        new_movement = applied_rule.newContent(**kw)
         start_date = configuration_dict.get('start_date', None)
         if start_date is not None:
           new_movement.recordProperty('start_date')
-- 
2.30.9