Commit 12bdfa8f authored by Sebastien Robin's avatar Sebastien Robin

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
parent ebb6ff26
...@@ -210,20 +210,39 @@ class SupplyLine(DeliveryLine, Path): ...@@ -210,20 +210,39 @@ class SupplyLine(DeliveryLine, Path):
# For generation of matrix lines # For generation of matrix lines
security.declareProtected( Permissions.ModifyPortalContent, '_setQuantityStepList' ) security.declareProtected( Permissions.ModifyPortalContent, '_setQuantityStepList' )
def _setQuantityStepList(self, value): def _setQuantityStepList(self, value):
self._baseSetQuantityStepList(value) self._baseSetQuantityStepList(value)
value = self.getQuantityStepList() value = self.getQuantityStepList()
value.sort() value.sort()
for pid in self.contentIds(filter={'portal_type': 'Predicate Group'}): for pid in self.contentIds(filter={'portal_type': 'Predicate Group'}):
self.deleteContent(pid) self.deleteContent(pid)
value = [None] + value + [None] if len(value) > 0:
for i in range(0, len(value) - 1): #value = value
p = self.newContent(id = 'quantity_range_%s' % i, portal_type = 'Predicate Group') value = [None] + value + [None]
p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=value[i], max=value[i+1]) # With this script, we canc change customize the title of the predicate
p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1]))) script = getattr(self,'SupplyLine_getTitle',None)
self._setVariationCategoryList(self.getVariationCategoryList())
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 from Products.ERP5Type.Utils import monkeyPatch
monkeyPatch(SupplyLineMixin,SupplyLine) monkeyPatch(SupplyLineMixin,SupplyLine)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment