Commit 2ae25bf9 authored by Romain Courteaud's avatar Romain Courteaud

Change implementation of _setQuantityStepList.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2246 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 31b40dba
...@@ -141,13 +141,11 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -141,13 +141,11 @@ class Resource(XMLMatrix, CoreResource, Variated):
if display_id is not None: if display_id is not None:
try: try:
#label = o.getProperty(display_id)
label = getattr(o, display_id, None) label = getattr(o, display_id, None)
if callable(label): if callable(label):
label = label() label = label()
except: except:
LOG('WARNING: Renderer', 0, LOG('WARNING: getVariationCategoryItemList', 0, 'Unable to call %s on %s' % (display_id, o.getRelativeUrl()))
'Unable to call %s on %s' % (display_id, o.getRelativeUrl()))
label = o.getRelativeUrl() label = o.getRelativeUrl()
if base: if base:
...@@ -627,18 +625,37 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -627,18 +625,37 @@ class Resource(XMLMatrix, CoreResource, Variated):
# 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)
if len(value) > 0: if len(value) > 0:
value = [None] + value + [None] value = value
for i in range(0, len(value) - 1):
p = self.newContent(id = 'quantity_range_%s' % i, portal_type = 'Predicate Group') # initialisation
i = 0
p = self.newContent(id = 'quantity_range_%s' % str(i), portal_type = 'Predicate Group')
p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=None, max=value[i])
p.setTitle(' quantity < %s' % repr(value[i]))
for i in range(0, len(value) -1 ):
p = self.newContent(id = 'quantity_range_%s' % str(i+1), portal_type = 'Predicate Group')
p.setCriterionPropertyList(('quantity', )) p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=value[i], max=value[i+1]) p.setCriterion('quantity', min=value[i], max=value[i+1])
p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1]))) p.setTitle('%s <= quantity < %s' % (repr(value[i]),repr(value[i+1])))
# end
i = i + 1
p = self.newContent(id = 'quantity_range_%s' % str(i+1), portal_type = 'Predicate Group')
p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=value[i], max=None)
p.setTitle(' quantity < %s' % repr(value[i]))
self.updateSupplyMatrix() self.updateSupplyMatrix()
# Predicate handling # Predicate handling
......
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