From 4fcc15556d734adcb2f3819bc792f9cb116754e3 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Thu, 15 Feb 2024 16:34:09 +0000 Subject: [PATCH] [FIX] account: fiscal positions: never map to an inactive tax When a tax is set to inactive, the fiscal positions mapping other taxes to it continued to apply, disregarding the fact that it shouldn't be used anymore. Not anymore with this fix. closes odoo/odoo#154646 X-original-commit: 07fa1b880875fc075555ca65f4ddd0cddb619979 Signed-off-by: Olivier Colson (oco) Signed-off-by: John Laterre (jol) --- addons/account/models/partner.py | 3 ++- addons/account/views/partner_view.xml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index 4eb3c3cd4c0..5eafd148ef9 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -111,7 +111,7 @@ class AccountFiscalPosition(models.Model): return taxes result = self.env['account.tax'] for tax in taxes: - taxes_correspondance = self.tax_ids.filtered(lambda t: t.tax_src_id == tax._origin) + taxes_correspondance = self.tax_ids.filtered(lambda t: t.tax_src_id == tax._origin and (not t.tax_dest_id or t.tax_dest_active)) result |= taxes_correspondance.tax_dest_id if taxes_correspondance else tax return result @@ -278,6 +278,7 @@ class AccountFiscalPositionTax(models.Model): company_id = fields.Many2one('res.company', string='Company', related='position_id.company_id', store=True) tax_src_id = fields.Many2one('account.tax', string='Tax on Product', required=True, check_company=True) tax_dest_id = fields.Many2one('account.tax', string='Tax to Apply', check_company=True) + tax_dest_active = fields.Boolean(related="tax_dest_id.active") _sql_constraints = [ ('tax_src_dest_uniq', diff --git a/addons/account/views/partner_view.xml b/addons/account/views/partner_view.xml index d455b6e30bf..8b219f91865 100644 --- a/addons/account/views/partner_view.xml +++ b/addons/account/views/partner_view.xml @@ -60,7 +60,8 @@ - + +