Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 10.0 sale_triple_discount #979

Merged
merged 1 commit into from Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions sale_triple_discount/README.rst
Expand Up @@ -80,6 +80,7 @@ Contributors
* David Vidal <david.vidal@tecnativa.com>
* Simone Rubino <simone.rubino@agilebg.com>
* Jacques-Etienne Baudoux (BCIM sprl) <je@bcim.be>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>

Maintainer
----------
Expand Down
2 changes: 1 addition & 1 deletion sale_triple_discount/__manifest__.py
Expand Up @@ -7,7 +7,7 @@

{
'name': 'Sale Triple Discount',
'version': '10.0.1.0.1',
'version': '10.0.1.1.0',
'category': 'Sales Management',
'author': 'ADHOC SA, '
'Agile Business Group, '
Expand Down
13 changes: 10 additions & 3 deletions sale_triple_discount/models/sale_order_line.py
Expand Up @@ -49,9 +49,16 @@ def _discount_fields(self):

@api.depends('discount2', 'discount3', 'discounting_type')
def _compute_amount(self):
prev_values = self.triple_discount_preprocess()
super(SaleOrderLine, self)._compute_amount()
self.triple_discount_postprocess(prev_values)
# we iterate and work line by line, because _compute_amount calls
# update, which can invalidate the cache, depending on the presence of
# other fields depending on the ones computed by that method. In that
# case the work done in preprocess would be lost as soon as the 1st
# line is updated, causing the following lines to ignore the discount2
# and discount3 fields.
for line in self:
prev_values = line.triple_discount_preprocess()
super(SaleOrderLine, line)._compute_amount()
line.triple_discount_postprocess(prev_values)

discount2 = fields.Float(
'Disc. 2 (%)',
Expand Down