[Erp5-report] r20854 - /erp5/trunk/products/ERP5/Document/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Apr 30 13:37:36 CEST 2008
Author: alex
Date: Wed Apr 30 13:37:33 2008
New Revision: 20854
URL: http://svn.erp5.org?rev=20854&view=rev
Log:
Patch by Julien Muchembled (jm at nexedi dot com):
* factorize getTotalPrice
* set default value of fast to 0
Modified:
erp5/trunk/products/ERP5/Document/DeliveryCell.py
erp5/trunk/products/ERP5/Document/DeliveryLine.py
erp5/trunk/products/ERP5/Document/OrderLine.py
Modified: erp5/trunk/products/ERP5/Document/DeliveryCell.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/DeliveryCell.py?rev=20854&r1=20853&r2=20854&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/DeliveryCell.py (original)
+++ erp5/trunk/products/ERP5/Document/DeliveryCell.py Wed Apr 30 13:37:33 2008
@@ -91,11 +91,18 @@
return self.getParentValue().getParentValue().isAccountable()
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice')
- def getPrice(self, context=None, REQUEST=None, **kw):
+ def getPrice(self, *args, **kw):
"""
call Movement.getPrice
"""
- return Movement.getPrice(self, context=context, REQUEST=REQUEST, **kw)
+ return Movement.getPrice(self, *args, **kw)
+
+ security.declareProtected(Permissions.AccessContentsInformation, 'getTotalPrice')
+ def getTotalPrice(self, *args, **kw):
+ """
+ call Movement.getTotalPrice
+ """
+ return Movement.getTotalPrice(self, *args, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getRootDeliveryValue')
Modified: erp5/trunk/products/ERP5/Document/DeliveryLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/DeliveryLine.py?rev=20854&r1=20853&r2=20854&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/DeliveryLine.py (original)
+++ erp5/trunk/products/ERP5/Document/DeliveryLine.py Wed Apr 30 13:37:33 2008
@@ -114,24 +114,18 @@
"""
return self.getParentValue().isAccountable() and (not self.hasCellContent())
- def _getTotalPrice(self, context, fast=1):
+ def _getTotalPrice(self, context, fast=0):
""" Returns the total price for this line or the cells it contains. """
- base_id = 'movement'
- if not self.hasCellContent(base_id=base_id):
- quantity = self.getQuantity() or 0.0
- price = self.getPrice(context=context) or 0.0
- return quantity * price
- else:
- if fast : # Use MySQL
- aggregate = self.DeliveryLine_zGetTotal()[0]
- return aggregate.total_price or 0.0
- return sum([ ( (cell.getQuantity() or 0) *
- (cell.getPrice(context=context) or 0))
- for cell in self.getCellValueList()])
+ if not self.hasCellContent(base_id='movement'):
+ return Movement._getTotalPrice(self, 0.0, context)
+ elif fast: # Use MySQL
+ return self.DeliveryLine_zGetTotal()[0].total_price or 0.0
+ return sum(cell.getTotalPrice(default=0.0, context=context)
+ for cell in self.getCellValueList())
security.declareProtected( Permissions.AccessContentsInformation,
'getTotalQuantity')
- def getTotalQuantity(self, fast=1):
+ def getTotalQuantity(self, fast=0):
"""
Returns the quantity if no cell or the total quantity if cells
Modified: erp5/trunk/products/ERP5/Document/OrderLine.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/OrderLine.py?rev=20854&r1=20853&r2=20854&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/OrderLine.py (original)
+++ erp5/trunk/products/ERP5/Document/OrderLine.py Wed Apr 30 13:37:33 2008
@@ -88,21 +88,10 @@
else: return quantity * price
if fast is argument true, then a SQL method will be used.
"""
- base_id = 'movement'
if self.hasLineContent():
- return sum(l.getTotalPrice() for l in
- self.contentValues(meta_type=self.meta_type))
- elif self.hasCellContent(base_id=base_id):
- if fast : # Use MySQL
- aggregate = self.DeliveryLine_zGetTotal()[0]
- return aggregate.total_price or 0.0
- return sum([ ( (cell.getQuantity() or 0) *
- (cell.getPrice(context=context) or 0))
- for cell in self.getCellValueList()])
- else:
- quantity = self.getQuantity() or 0.0
- price = self.getPrice(context=context) or 0.0
- return quantity * price
+ return sum(l.getTotalPrice(context=context)
+ for l in self.contentValues(meta_type=self.meta_type))
+ return DeliveryLine._getTotalPrice(self, context=context, fast=fast)
security.declareProtected(Permissions.AccessContentsInformation,
'getTotalQuantity')
More information about the Erp5-report
mailing list