From c79cdf717b30f0680fa2e3d7a6acea95978afd88 Mon Sep 17 00:00:00 2001 From: oco-odoo Date: Thu, 1 Jul 2021 12:53:18 +0000 Subject: [PATCH] [FIX] l10n_eu_service: don't duplicate OSS taxes on refresh of an existing rate To reproduce: 1) Install an European CoA and make sure the OSS mapping for its taxes has been generated (either installing l10n_eu_service before, or clikcing the "refresh tax mapping" button, in the settings) 2) Create a new tax with the same rate as one of your original taxes 3) Click on "refresh tax mapping" ===> Instead of reusing the OSS tax mapped with the other tax having the same rate, a new tax with the same name has been created. X-original-commit: 6f6386ed0374cea143541add69c269f44b098050 --- addons/l10n_eu_service/models/res_company.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/l10n_eu_service/models/res_company.py b/addons/l10n_eu_service/models/res_company.py index bc568a98fc0..68f435593c7 100644 --- a/addons/l10n_eu_service/models/res_company.py +++ b/addons/l10n_eu_service/models/res_company.py @@ -33,7 +33,6 @@ class Company(models.Model): ('tax_group_id', 'not in', oss_tax_groups.mapped('res_id'))]) for country in eu_countries - company.account_fiscal_country_id: mapping = [] - foreign_taxes = {} fpos = self.env['account.fiscal.position'].search([ ('country_id', '=', country.id), ('company_id', '=', company.id), @@ -46,6 +45,9 @@ class Company(models.Model): 'company_id': company.id, 'auto_apply': True, }) + + foreign_taxes = {tax.amount: tax for tax in fpos.tax_ids.tax_dest_id if tax.amount_type == 'percent'} + for domestic_tax in taxes: tax_amount = EU_TAX_MAP.get((company.account_fiscal_country_id.code, domestic_tax.amount, country.code), False) if tax_amount and domestic_tax not in fpos.tax_ids.tax_src_id: