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):
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')
......
......@@ -306,7 +306,11 @@ class Movement(XMLObject, Amount):
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')
......
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