Skip to content

Commit

Permalink
temp rebasing PR 794 (338b08a)
Browse files Browse the repository at this point in the history
  • Loading branch information
roboadhoc committed Mar 21, 2024
2 parents 24acd80 + 338b08a commit 1a525b8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions sale_three_discounts/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,19 @@ def inverse_vals(self, vals_list):
'discount1': vals.get('discount'),
})

@api.depends('discount1', 'discount2', 'discount3')
@api.depends('discount1', 'discount2', 'discount3', 'product_id')
def _compute_discounts(self):
website_id = self._context.get('website_id')
for rec in self:
discount_factor = 1.0
for discount in [rec.discount1, rec.discount2, rec.discount3]:
discount_factor = discount_factor * (
(100.0 - discount) / 100.0)
rec.discount = 100.0 - (discount_factor * 100.0)
if website_id:
rec._compute_discount()
rec.discount1 = rec.discount
else:
discount_factor = 1.0
for discount in [rec.discount1, rec.discount2, rec.discount3]:
discount_factor = discount_factor * (
(100.0 - discount) / 100.0)
rec.discount = 100.0 - (discount_factor * 100.0)

@api.onchange('product_id')
def _onchange_discounts(self):
Expand Down

0 comments on commit 1a525b8

Please sign in to comment.