Commit 1abc4bac authored by Julien Muchembled's avatar Julien Muchembled

amount_generator: simplify AggregatedAmountList

multiplyQuantity() is dead code since
commit 74838d44
parent 4db1663c
...@@ -28,10 +28,8 @@ ...@@ -28,10 +28,8 @@
############################################################################## ##############################################################################
import zope.interface import zope.interface
from AccessControl import allow_class
from Products.ERP5Type import interfaces from Products.ERP5Type import interfaces
from Products.ERP5Type.Globals import InitializeClass
from Products.PythonScripts.Utility import allow_class
from AccessControl import ClassSecurityInfo
class AggregatedAmountList(list): class AggregatedAmountList(list):
""" """
...@@ -40,42 +38,26 @@ class AggregatedAmountList(list): ...@@ -40,42 +38,26 @@ class AggregatedAmountList(list):
""" """
zope.interface.implements(interfaces.IAmountList) zope.interface.implements(interfaces.IAmountList)
meta_type = "AggregatedAmountList"
security = ClassSecurityInfo()
# security.declareObjectPublic()
security.declarePublic('getTotalPrice')
def getTotalPrice(self): def getTotalPrice(self):
""" """
Return total base price Return total base price
""" """
result = sum(filter(lambda y: y is not None, result = 0
map(lambda x: x.getTotalPrice(), self))) for amount in self:
total_price = amount.getTotalPrice()
if total_price:
result += total_price
return result return result
security.declarePublic('getTotalDuration')
def getTotalDuration(self): def getTotalDuration(self):
""" """
Return total duration Return total duration
""" """
result = sum(filter(lambda y: y is not None, result = 0
map(lambda x: x.getDuration(), self))) for amount in self:
duration = amount.getDuration()
if duration:
result += duration
return result return result
def multiplyQuantity(self,context=None):
"""
Take into account the quantity of the
context. Change the quantity of each element.
"""
quantity = None
if context is not None:
if context.getQuantity() is not None:
quantity = context.getQuantity()
if quantity is not None:
for x in self:
previous_quantity = x.getQuantity()
if previous_quantity is not None:
x.edit(quantity=context.getQuantity()*previous_quantity)
InitializeClass(AggregatedAmountList)
allow_class(AggregatedAmountList) allow_class(AggregatedAmountList)
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