From 73de6497969891aaa46d7f4e898a46f06b428053 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 28 Sep 2023 15:29:15 +0200 Subject: [PATCH] [FIX] l10n_es_edi_sii: export regimen key should depend on taxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We made it depend on the partner country, but it is better to identify it through the tax being used. E.g. it is only the exportation of goods that is needed to change the regimen and not the services. We also needed to change the test, because we used E2 with a Belgian partner. opw-3514270 closes odoo/odoo#137184 X-original-commit: 14d5be171e238d7aa12f513659929b5b940eea78 Signed-off-by: William André (wan) Signed-off-by: Josse Colpaert --- addons/l10n_es_edi_sii/models/account_edi_format.py | 7 ++----- addons/l10n_es_edi_sii/tests/test_edi_xml.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/l10n_es_edi_sii/models/account_edi_format.py b/addons/l10n_es_edi_sii/models/account_edi_format.py index 54815554973..cea366d483c 100644 --- a/addons/l10n_es_edi_sii/models/account_edi_format.py +++ b/addons/l10n_es_edi_sii/models/account_edi_format.py @@ -286,11 +286,8 @@ class AccountEdiFormat(models.Model): **partner_info, 'NombreRazon': com_partner.name[:120], } - - if not com_partner.country_id or com_partner.country_id.code in eu_country_codes: - invoice_node['ClaveRegimenEspecialOTrascendencia'] = '01' - else: - invoice_node['ClaveRegimenEspecialOTrascendencia'] = '02' + export_exempts = invoice.invoice_line_ids.tax_ids.filtered(lambda t: t.l10n_es_exempt_reason == 'E2') + invoice_node['ClaveRegimenEspecialOTrascendencia'] = '02' if export_exempts else '01' else: info['IDFactura']['IDEmisorFactura'] = partner_info info['IDFactura']['NumSerieFacturaEmisor'] = invoice.ref[:60] diff --git a/addons/l10n_es_edi_sii/tests/test_edi_xml.py b/addons/l10n_es_edi_sii/tests/test_edi_xml.py index cbaae0b6b7a..1132a3bcf4f 100644 --- a/addons/l10n_es_edi_sii/tests/test_edi_xml.py +++ b/addons/l10n_es_edi_sii/tests/test_edi_xml.py @@ -446,7 +446,7 @@ class TestEdiXmls(TestEsEdiCommon): 'PeriodoLiquidacion': {'Ejercicio': '2019', 'Periodo': '01'}, 'FacturaExpedida': { 'TipoFactura': 'F1', - 'ClaveRegimenEspecialOTrascendencia': '01', + 'ClaveRegimenEspecialOTrascendencia': '02', 'DescripcionOperacion': 'manual', 'TipoDesglose': { 'DesgloseTipoOperacion': {