Commit af571b3f authored by Yusei Tahara's avatar Yusei Tahara

Added TypeBasedMethod for getTotalPrice method. This is useful to customize...

Added TypeBasedMethod for getTotalPrice method. This is useful to customize price round procedure, for example.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25298 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 36a04888
...@@ -119,17 +119,23 @@ class Delivery(XMLObject, ImmobilisationDelivery): ...@@ -119,17 +119,23 @@ class Delivery(XMLObject, ImmobilisationDelivery):
So if the order is not in the catalog, getTotalPrice(fast=1) So if the order is not in the catalog, getTotalPrice(fast=1)
will return 0, this is not a bug. will return 0, this is not a bug.
""" """
if not fast : result = None
if not fast:
kw.setdefault( 'portal_type', kw.setdefault( 'portal_type',
self.getPortalDeliveryMovementTypeList()) self.getPortalDeliveryMovementTypeList())
return sum([ line.getTotalPrice(fast=0) for line in result = sum([ line.getTotalPrice(fast=0) for line in
self.objectValues(**kw) ]) self.objectValues(**kw) ])
kw['explanation_uid'] = self.getUid() else:
kw.update(self.portal_catalog.buildSQLQuery(**kw)) kw['explanation_uid'] = self.getUid()
if src__: kw.update(self.portal_catalog.buildSQLQuery(**kw))
return self.Delivery_zGetTotal(src__=1, **kw) if src__:
aggregate = self.Delivery_zGetTotal(**kw)[0] return self.Delivery_zGetTotal(src__=1, **kw)
return aggregate.total_price or 0 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, security.declareProtected(Permissions.AccessContentsInformation,
'getTotalNetPrice') 'getTotalNetPrice')
......
...@@ -306,7 +306,11 @@ class Movement(XMLObject, Amount): ...@@ -306,7 +306,11 @@ class Movement(XMLObject, Amount):
default = None default = None
tmp_context = self.asContext(context=context, REQUEST=REQUEST, **kw) 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, security.declareProtected( Permissions.AccessContentsInformation,
'getTotalQuantity') '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