From 12bdfa8f639b2f7b0c2a15cd40cc50884cd06877 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Tue, 5 Apr 2005 09:23:26 +0000
Subject: [PATCH] updated setQuantityStepList so taht it can supports a script
 in order to set the title

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

diff --git a/product/ERP5/Document/SupplyLine.py b/product/ERP5/Document/SupplyLine.py
index 9468244f7c..d04365364a 100755
--- a/product/ERP5/Document/SupplyLine.py
+++ b/product/ERP5/Document/SupplyLine.py
@@ -210,20 +210,39 @@ class SupplyLine(DeliveryLine, Path):
 
     # For generation of matrix lines
     security.declareProtected( Permissions.ModifyPortalContent, '_setQuantityStepList' )
-    def _setQuantityStepList(self, value):        
+    def _setQuantityStepList(self, value):
+
       self._baseSetQuantityStepList(value)
       value = self.getQuantityStepList()
       value.sort()
+
       for pid in self.contentIds(filter={'portal_type': 'Predicate Group'}):
         self.deleteContent(pid)
-      value = [None] + value + [None]
-      for i in range(0, len(value) - 1):
-        p = self.newContent(id = 'quantity_range_%s' % i, portal_type = 'Predicate Group')
-        p.setCriterionPropertyList(('quantity', ))
-        p.setCriterion('quantity', min=value[i], max=value[i+1])              
-        p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1])))
-      self._setVariationCategoryList(self.getVariationCategoryList())
-
+      if len(value) > 0:
+        #value = value
+        value = [None] + value + [None]
+
+        # With this script, we canc change customize the title of the predicate
+        script = getattr(self,'SupplyLine_getTitle',None)
+
+        for i in range(0, len(value) -1  ):
+          min = value[i]
+          max = value[i+1]
+          p = self.newContent(id = 'quantity_range_%s' % str(i), portal_type = 'Predicate Group')
+          p.setCriterionPropertyList(('quantity', ))
+          p.setCriterion('quantity', min=min, max=max)
+          if script is not None:
+            title = script(min=min,max=max)
+            p.setTitle(title)
+          else:
+            if min is None:
+              p.setTitle(' quantity < %s' % repr(max))
+            elif max is None:
+              p.setTitle('%s <= quantity' % repr(min))
+            else:
+              p.setTitle('%s <= quantity < %s' % (repr(min),repr(max)))
+
+      self.updateCellRange(base_id='path')
 
 from Products.ERP5Type.Utils import monkeyPatch
 monkeyPatch(SupplyLineMixin,SupplyLine)        
-- 
2.30.9