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