From 43c602457bfd4ca8dd6fe99bdfe041b4bfec6cf3 Mon Sep 17 00:00:00 2001 From: Borruso Date: Thu, 9 Nov 2023 16:26:47 +0100 Subject: [PATCH] [FIX] l10n_it_account_stamp: add stamp by comparing price in company currency --- l10n_it_account_stamp/models/account_move.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/l10n_it_account_stamp/models/account_move.py b/l10n_it_account_stamp/models/account_move.py index fac2a1555300..1140c2b16f72 100644 --- a/l10n_it_account_stamp/models/account_move.py +++ b/l10n_it_account_stamp/models/account_move.py @@ -21,7 +21,7 @@ def is_tax_stamp_applicable(self): raise UserError(_("Missing tax stamp product in company settings!")) total_tax_base = sum( ( - inv_tax.price_subtotal + abs(inv_tax.balance) for inv_tax in self.line_ids.filtered( lambda line: set(line.tax_ids.ids) & set(stamp_product_id.stamp_apply_tax_ids.ids) @@ -32,14 +32,13 @@ def is_tax_stamp_applicable(self): return total_tax_base >= stamp_product_id.stamp_apply_min_total_base @api.depends( - "invoice_line_ids.price_subtotal", - "line_ids.price_total", + "line_ids.balance", "currency_id", "company_id", "invoice_date", "move_type", "manually_apply_tax_stamp", - "invoice_line_ids.tax_ids", + "line_ids.tax_ids", ) def _compute_tax_stamp(self): for invoice in self: @@ -71,13 +70,16 @@ def add_tax_stamp_line(self): _("Missing account income configuration for %s") % stamp_product_id.name ) + price_unit = inv.company_currency_id._convert( + stamp_product_id.list_price, inv.currency_id, inv.company_id, inv.date + ) invoice_line_vals = { "move_id": inv.id, "product_id": stamp_product_id.id, "name": stamp_product_id.description_sale, "sequence": 99999, "account_id": stamp_account.id, - "price_unit": stamp_product_id.list_price, + "price_unit": price_unit, "quantity": 1, "display_type": "product", "product_uom_id": stamp_product_id.uom_id.id,