Commit 67b1f228 authored by Jérome Perrin's avatar Jérome Perrin

Do not override builtins min and max, minor style changes.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8504 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 67348c3a
......@@ -27,25 +27,17 @@
#
##############################################################################
import ExtensionClass
from Globals import InitializeClass, PersistentMapping
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.XMLMatrix import XMLMatrix
from Products.ERP5.Document.DeliveryLine import DeliveryLine
from Products.ERP5.Document.Movement import Movement
from Products.ERP5.Document.Path import Path
from Products.ERP5Type.Utils import convertToUpperCase
from zLOG import LOG
class SupplyLine(DeliveryLine, Path):
"""
A DeliveryLine object allows to implement lines in
Deliveries (packing list, order, invoice, etc.)
It may include a price (for insurance, for customs, for invoices,
for orders)
"""A Supply Line is a path to define price
"""
meta_type = 'ERP5 Supply Line'
......@@ -54,14 +46,14 @@ class SupplyLine(DeliveryLine, Path):
isPortalContent = 1
isRADContent = 1
isPredicate = 1
isAccountable = 0
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative interfaces
__implements__ = ( Interface.Variated, )
__implements__ = ( Interface.Variated,
Interface.Predicate )
# Declarative properties
property_sheets = ( PropertySheet.Base
......@@ -116,8 +108,7 @@ class SupplyLine(DeliveryLine, Path):
security.declareProtected(Permissions.AccessContentsInformation,
'isAccountable')
def isAccountable(self):
"""
Returns 1 if this needs to be accounted
"""Supply Line are not accounted.
"""
return 0
......@@ -146,7 +137,8 @@ class SupplyLine(DeliveryLine, Path):
# XMLMatrix methods
# XXX to be removed if possible
#############################################
security.declareProtected(Permissions.ModifyPortalContent, 'hasCellContent')
security.declareProtected(Permissions.AccessContentsInformation,
'hasCellContent')
def hasCellContent(self, base_id='path'):
"""
This method can be overriden
......@@ -161,7 +153,7 @@ class SupplyLine(DeliveryLine, Path):
"""
return XMLMatrix.getCellValueList(self, base_id=base_id)
security.declareProtected(Permissions.View, 'getCell')
security.declareProtected(Permissions.AccessContentsInformation, 'getCell')
def getCell(self, *kw , **kwd):
"""
This method can be overriden
......@@ -209,7 +201,8 @@ class SupplyLine(DeliveryLine, Path):
self.getQuantityPredicateIdList(price_parameter)]
return result
security.declareProtected(Permissions.View, 'getQuantityStepList')
security.declareProtected(Permissions.AccessContentsInformation,
'getQuantityStepList')
def getQuantityStepList(self, price_parameter="base_price"):
"""
Return predicate step related to a price_parameter
......@@ -225,38 +218,40 @@ class SupplyLine(DeliveryLine, Path):
'updateQuantityPredicate')
def updateQuantityPredicate(self, price_parameter):
"""
Update the quantity predicate
Update the quantity predicate for this price parameter
"""
value = self.getQuantityStepList(price_parameter)
value.sort()
# XXX Hardcoded portal type name
quantity_step_list = self.getQuantityStepList(price_parameter)
quantity_step_list.sort()
# remove old predicates
for pid in self.getQuantityPredicateIdList(price_parameter):
self.deleteContent(pid)
if len(value) > 0:
#value = value
value = [None] + value + [None]
# With this script, we can change customize the title of the
# predicate
if quantity_step_list:
quantity_step_list = [None] + quantity_step_list + [None]
# With this script, we can change the title of the predicate
script = getattr(self, 'SupplyLine_getTitle', None)
predicate_id_start_with = "quantity_range"
if price_parameter != "base_price":
predicate_id_start_with = "%s_%s" % \
(price_parameter, predicate_id_start_with)
for i in range(0, len(value)-1):
min = value[i]
max = value[i+1]
for i in range(0, len(quantity_step_list)-1):
min_quantity = quantity_step_list[i]
max_quantity = quantity_step_list[i+1]
# XXX Hardcoded portal type name
p = self.newContent(id='%s_%s' % (predicate_id_start_with, str(i)),
portal_type = 'Predicate')
p.setCriterionPropertyList(('quantity', ))
p.setCriterion('quantity', min=min, max=max)
p.setCriterion('quantity', min=min_quantity, max=max_quantity)
if script is not None:
title = script(min=min, max=max)
title = script(min=min_quantity, max=max_quantity)
p.setTitle(title)
else:
if min is None:
p.setTitle(' quantity < %s' % repr(max))
elif max is None:
p.setTitle('%s <= quantity' % repr(min))
if min_quantity is None:
p.setTitle('quantity < %s' % max_quantity)
elif max_quantity is None:
p.setTitle('%s <= quantity' % min_quantity)
else:
p.setTitle('%s <= quantity < %s' % (repr(min), repr(max)))
p.setTitle('%s <= quantity < %s' % (min_quantity, max_quantity))
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