[Erp5-report] r25298 - in /erp5/trunk/products/ERP5/Document: Delivery.py Movement.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jan 26 06:21:02 CET 2009


Author: yusei
Date: Mon Jan 26 06:21:01 2009
New Revision: 25298

URL: http://svn.erp5.org?rev=25298&view=rev
Log:
Added TypeBasedMethod for getTotalPrice method. This is useful to customize price round procedure, for example.

Modified:
    erp5/trunk/products/ERP5/Document/Delivery.py
    erp5/trunk/products/ERP5/Document/Movement.py

Modified: erp5/trunk/products/ERP5/Document/Delivery.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Delivery.py?rev=25298&r1=25297&r2=25298&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Delivery.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Delivery.py [utf8] Mon Jan 26 06:21:01 2009
@@ -119,17 +119,23 @@
         So if the order is not in the catalog, getTotalPrice(fast=1)
         will return 0, this is not a bug.
       """
-      if not fast :
+      result = None
+      if not fast:
         kw.setdefault( 'portal_type',
                        self.getPortalDeliveryMovementTypeList())
-        return sum([ line.getTotalPrice(fast=0) for line in
-                        self.objectValues(**kw) ])
-      kw['explanation_uid'] = self.getUid()
-      kw.update(self.portal_catalog.buildSQLQuery(**kw))
-      if src__:
-        return self.Delivery_zGetTotal(src__=1, **kw)
-      aggregate = self.Delivery_zGetTotal(**kw)[0]
-      return aggregate.total_price or 0
+        result = sum([ line.getTotalPrice(fast=0) for line in
+                       self.objectValues(**kw) ])
+      else:
+        kw['explanation_uid'] = self.getUid()
+        kw.update(self.portal_catalog.buildSQLQuery(**kw))
+        if src__:
+          return self.Delivery_zGetTotal(src__=1, **kw)
+        aggregate = self.Delivery_zGetTotal(**kw)[0]
+        result = aggregate.total_price or 0
+      method = self._getTypeBasedMethod('getTotalPrice')
+      if method is None:
+        return method(result)
+      return result
 
     security.declareProtected(Permissions.AccessContentsInformation,
                               'getTotalNetPrice')

Modified: erp5/trunk/products/ERP5/Document/Movement.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Movement.py?rev=25298&r1=25297&r2=25298&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Movement.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Movement.py [utf8] Mon Jan 26 06:21:01 2009
@@ -306,7 +306,11 @@
       default = None
     
     tmp_context = self.asContext(context=context, REQUEST=REQUEST, **kw)
-    return self._getTotalPrice(default=default, context=tmp_context, fast=fast, **kw)
+    result = self._getTotalPrice(default=default, context=tmp_context, fast=fast, **kw)
+    method = self._getTypeBasedMethod('getTotalPrice')
+    if method is None:
+      return result
+    return method(result)
 
   security.declareProtected( Permissions.AccessContentsInformation,
                              'getTotalQuantity')




More information about the Erp5-report mailing list