Skip to content

Commit

Permalink
account_invoice_pricelist: Use setter for triple discount
Browse files Browse the repository at this point in the history
  • Loading branch information
grindtildeath committed Jun 28, 2024
1 parent d2296c7 commit 528ae9a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions account_invoice_pricelist/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _get_price_with_pricelist(self):
self.tax_ids,
self.company_id,
)
self.with_context(check_move_validity=False).discount = 0.0
self._set_discount(0.0)
return price_unit
else:
rule_id = self.env["product.pricelist.item"].browse(rule_id)
Expand All @@ -124,7 +124,13 @@ def _get_price_with_pricelist(self):
target_currency=self.currency_id,
)
price_unit = max(base_price, final_price)
self.with_context(
check_move_validity=False
).discount = self._calculate_discount(base_price, final_price)
self._set_discount(self._calculate_discount(base_price, final_price))
return price_unit

def _set_discount(self, amount):
if self.env["account.move.line"]._fields.get("discount1", False):
# OCA/account_invoice_triple_discount is installed
fname = "discount1"

Check warning on line 133 in account_invoice_pricelist/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_pricelist/models/account_move.py#L133

Added line #L133 was not covered by tests
else:
fname = "discount"
self.with_context(check_move_validity=False)[fname] = amount

0 comments on commit 528ae9a

Please sign in to comment.