Commit 750b01da authored by Julien Muchembled's avatar Julien Muchembled

amount_generator: fix aggregation with rounding proxies

parent c34015d6
...@@ -31,6 +31,7 @@ from collections import defaultdict ...@@ -31,6 +31,7 @@ from collections import defaultdict
import zope.interface import zope.interface
from AccessControl import allow_class from AccessControl import allow_class
from Products.ERP5Type import interfaces from Products.ERP5Type import interfaces
from Products.ERP5.Document.RoundingModel import RoundingProxy
class GeneratedAmountList(list): class GeneratedAmountList(list):
""" """
...@@ -92,10 +93,14 @@ class GeneratedAmountList(list): ...@@ -92,10 +93,14 @@ class GeneratedAmountList(list):
# but it is not a good idea, especially when the first expand causes # but it is not a good idea, especially when the first expand causes
# non-zero quantity and then quantity becomes zero. # non-zero quantity and then quantity becomes zero.
aggregate = newTempAmount(amount.aq_parent, '', notify_workflow=False) aggregate = newTempAmount(amount.aq_parent, '', notify_workflow=False)
result_list.append(aggregate) aggregate.__dict__.update(amount.aq_base.__dict__)
aggregate.__dict__.update(amount.__dict__)
aggregate._setQuantity(quantity) aggregate._setQuantity(quantity)
if isinstance(amount, RoundingProxy):
aggregate = amount.getPortalObject().portal_roundings.getRoundingProxy(
aggregate)
else:
del aggregate._base del aggregate._base
result_list.append(aggregate)
return result_list return result_list
def split(self): def split(self):
......
...@@ -474,7 +474,6 @@ class AmountGeneratorMixin: ...@@ -474,7 +474,6 @@ class AmountGeneratorMixin:
property_dict['causality_value_list'][-1] property_dict['causality_value_list'][-1]
.getRelativeUrl().replace('/', '_'), .getRelativeUrl().replace('/', '_'),
notify_workflow=False) notify_workflow=False)
amount._base = delivery_amount
amount._setCategoryList(property_dict.pop('category_list', ())) amount._setCategoryList(property_dict.pop('category_list', ()))
if amount.getQuantityUnit(): if amount.getQuantityUnit():
del property_dict['quantity_unit'] del property_dict['quantity_unit']
...@@ -489,6 +488,7 @@ class AmountGeneratorMixin: ...@@ -489,6 +488,7 @@ class AmountGeneratorMixin:
if rounding: if rounding:
# We hope here that rounding is sufficient at line level # We hope here that rounding is sufficient at line level
amount = getRoundingProxy(amount, context=self) amount = getRoundingProxy(amount, context=self)
amount._base = delivery_amount
result.append(amount) result.append(amount)
# Contribute # Contribute
quantity *= property_dict.get('price', 1) quantity *= property_dict.get('price', 1)
......
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