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