Skip to content

Commit

Permalink
Merge PR #1751 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by grindtildeath
  • Loading branch information
OCA-git-bot committed Nov 26, 2024
2 parents 63c9d01 + 528ae9a commit 140d726
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 @@ -105,7 +105,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 @@ -125,7 +125,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"
else:
fname = "discount"
self.with_context(check_move_validity=False)[fname] = amount

0 comments on commit 140d726

Please sign in to comment.