From b5fd4b19dbdf3bf7def3fa5c217f395b0d176616 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 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/l10n_it_account_stamp/models/account_move.py b/l10n_it_account_stamp/models/account_move.py index 68e8f8ffd29c..34c96c4c1989 100644 --- a/l10n_it_account_stamp/models/account_move.py +++ b/l10n_it_account_stamp/models/account_move.py @@ -31,7 +31,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) @@ -42,14 +42,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: @@ -81,6 +80,10 @@ def add_tax_stamp_line(self): _("Missing account income configuration for %s") % stamp_product_id.name ) + currency_id = stamp_product_id.currency_id or inv.company_currency_id + price_unit = 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, @@ -88,7 +91,7 @@ def add_tax_stamp_line(self): "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,