Commit 48358df5 authored by Jérome Perrin's avatar Jérome Perrin

Propagate default and fast arguments in _getTotalPrice and getTotalPrice

Add fast parameter in Movement._getTotalPrice (ignored, but here for consistency)
Update _getTotalPrice / getTotalPrice on some Movement subclasses to support default argument (default is still 0.0)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21188 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3c50f21
......@@ -98,11 +98,11 @@ class DeliveryCell(MappedValue, Movement, ImmobilisationMovement):
return Movement.getPrice(self, *args, **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getTotalPrice')
def getTotalPrice(self, *args, **kw):
def getTotalPrice(self, default=0.0, *args, **kw):
"""
call Movement.getTotalPrice
"""
return Movement.getTotalPrice(self, *args, **kw)
return Movement.getTotalPrice(self, default=default, *args, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getRootDeliveryValue')
......
......@@ -114,10 +114,10 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated,
"""
return self.getParentValue().isAccountable() and (not self.hasCellContent())
def _getTotalPrice(self, context, fast=0):
def _getTotalPrice(self, default=0.0, context=None, fast=0):
""" Returns the total price for this line or the cells it contains. """
if not self.hasCellContent(base_id='movement'):
return Movement._getTotalPrice(self, 0.0, context)
return Movement._getTotalPrice(self, default=default, context=context)
elif fast: # Use MySQL
return self.DeliveryLine_zGetTotal()[0].total_price or 0.0
return sum(cell.getTotalPrice(default=0.0, context=context)
......
......@@ -203,7 +203,7 @@ class Movement(XMLObject, Amount):
if operand_dict is not None:
return operand_dict['price']
def _getTotalPrice(self, default=None, context=None):
def _getTotalPrice(self, default=None, context=None, fast=0):
price = self.getPrice(context=context)
quantity = self.getQuantity()
if isinstance(price, (int, float)) and \
......@@ -297,7 +297,7 @@ class Movement(XMLObject, Amount):
default = None
tmp_context = self.asContext(context=context, REQUEST=REQUEST, **kw)
return self._getTotalPrice(context=tmp_context, **kw)
return self._getTotalPrice(default=default, context=tmp_context, fast=fast, **kw)
security.declareProtected( Permissions.AccessContentsInformation,
'getTotalQuantity')
......
......@@ -84,10 +84,11 @@ class OrderCell(DeliveryCell):
security.declareProtected(Permissions.AccessContentsInformation,
'getTotalPrice')
def getTotalPrice(self, *args, **kw):
def getTotalPrice(self, default=0.0, *args, **kw):
"only return a value if self is a movement"
if not self.isMovement(): return 0.0
return DeliveryCell.getTotalPrice(self, *args, **kw)
if not self.isMovement():
return default
return DeliveryCell.getTotalPrice(self, default=default, *args, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getTotalQuantity')
......
......@@ -80,7 +80,7 @@ class OrderLine(DeliveryLine):
transactional_variable[call_method_key] = result
return result
def _getTotalPrice(self, context, fast=0):
def _getTotalPrice(self, default=0.0, context=None, fast=0):
"""Returns the total price for this order line.
if hasLineContent: return sum of lines total price
......@@ -91,7 +91,10 @@ class OrderLine(DeliveryLine):
if self.hasLineContent():
return sum(l.getTotalPrice(context=context)
for l in self.contentValues(meta_type=self.meta_type))
return DeliveryLine._getTotalPrice(self, context=context, fast=fast)
return DeliveryLine._getTotalPrice(self,
default=default,
context=context,
fast=fast)
security.declareProtected(Permissions.AccessContentsInformation,
'getTotalQuantity')
......
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