diff --git a/addons/l10n_es/data/account_tax_data.xml b/addons/l10n_es/data/account_tax_data.xml
index b8af156e2bd..b239f530d53 100644
--- a/addons/l10n_es/data/account_tax_data.xml
+++ b/addons/l10n_es/data/account_tax_data.xml
@@ -1004,6 +1004,40 @@
(0,0, {'repartition_type': 'tax'}),
]"/>
+
+ No sujeto y acogidas a la OSS (Servicios)
+ sale
+ No sujeto y acogidas a la OSS (Servicios)
+
+
+ percent
+
+
+
+
No sujeto (Bienes)
sale
@@ -1027,6 +1061,40 @@
(0,0, {'repartition_type': 'tax'}),
]"/>
+
+ No sujeto y acogidas a la OSS (Bienes)
+ sale
+ No sujeto y acogidas a la OSS (Bienes)
+
+
+ percent
+
+
+
+
Extracomunitario (Servicios)
sale
diff --git a/addons/l10n_eu_oss/models/eu_tag_map.py b/addons/l10n_eu_oss/models/eu_tag_map.py
index 31b74f8b7f5..0cd829b100d 100644
--- a/addons/l10n_eu_oss/models/eu_tag_map.py
+++ b/addons/l10n_eu_oss/models/eu_tag_map.py
@@ -199,7 +199,7 @@ EU_TAG_MAP = {
},
# Spain
'l10n_es.account_chart_template_common': {
- 'invoice_base_tag': None,
+ 'invoice_base_tag': "l10n_es.mod_303_124",
'invoice_tax_tag': None,
'refund_base_tag': None,
'refund_tax_tag': None,
diff --git a/addons/l10n_eu_oss/models/res_company.py b/addons/l10n_eu_oss/models/res_company.py
index ef595dc1fad..1d5a1c22321 100644
--- a/addons/l10n_eu_oss/models/res_company.py
+++ b/addons/l10n_eu_oss/models/res_company.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import api, models, Command
-from .eu_tax_map import EU_TAX_MAP
+from odoo import Command, api, models
from .eu_tag_map import EU_TAG_MAP
+from .eu_tax_map import EU_TAX_MAP
class Company(models.Model):
@@ -127,7 +127,7 @@ class Company(models.Model):
def _get_oss_tags(self):
oss_tag = self.env.ref('l10n_eu_oss.tag_oss')
- [chart_template_xml_id] = self.chart_template_id.get_external_id().values()
+ [chart_template_xml_id] = self.chart_template_id.parent_id.get_external_id().values() or self.chart_template_id.get_external_id().values()
tag_for_country = EU_TAG_MAP.get(chart_template_xml_id, {
'invoice_base_tag': None,
'invoice_tax_tag': None,
@@ -135,11 +135,11 @@ class Company(models.Model):
'refund_tax_tag': None,
})
- return {
- repartition_line_key: (
- self.env.ref(tag_xml_id)._get_matching_tags().filtered(lambda t: not t.tax_negate)
- if tag_xml_id
- else self.env['account.account.tag']
- ) + oss_tag
- for repartition_line_key, tag_xml_id in tag_for_country.items()
- }
+ mapping = {}
+ for repartition_line_key, tag_xml_id in tag_for_country.items():
+ tag = self.env.ref(tag_xml_id) if tag_xml_id else self.env['account.account.tag']
+ if tag and tag._name == "account.report.expression":
+ tag = tag._get_matching_tags().filtered(lambda t: not t.tax_negate)
+ mapping[repartition_line_key] = tag + oss_tag
+
+ return mapping
diff --git a/addons/l10n_eu_oss/tests/test_oss.py b/addons/l10n_eu_oss/tests/test_oss.py
index 178f62a7e37..78629cdc030 100644
--- a/addons/l10n_eu_oss/tests/test_oss.py
+++ b/addons/l10n_eu_oss/tests/test_oss.py
@@ -21,6 +21,10 @@ class TestOSSBelgium(AccountTestInvoicingCommon):
cls.company_data['company']._map_eu_taxes()
def test_country_tag_from_belgium(self):
+ """
+ This test ensure that xml_id from `account.tax.report.line` in the EU_TAG_MAP are processed correctly by the oss
+ tax creation mechanism.
+ """
# get an eu country which isn't the current one:
another_eu_country_code = (self.env.ref('base.europe').country_ids - self.company_data['company'].country_id)[0].code
tax_oss = self.env['account.tax'].search([('name', 'ilike', f'%{another_eu_country_code}%')], limit=1)
@@ -41,6 +45,43 @@ class TestOSSBelgium(AccountTestInvoicingCommon):
self.assertIn(expected_tag_id, oss_tag_id, f"{doc_type} tag from Belgian CoA not correctly linked")
+@tagged('post_install', 'post_install_l10n', '-at_install')
+class TestOSSSpain(AccountTestInvoicingCommon):
+
+ @classmethod
+ def setUpClass(cls, chart_template_ref='l10n_es.account_chart_template_common'):
+ try:
+ super().setUpClass(chart_template_ref=chart_template_ref)
+ except ValueError as e:
+ if e.args[0] == "External ID not found in the system: l10n_es.account_chart_template_data":
+ cls.skipTest(cls, reason="Spanish CoA is required for this testSuite but l10n_es isn't installed")
+ else:
+ raise e
+ cls.company_data['company'].country_id = cls.env.ref('base.es')
+ cls.company_data['company']._map_eu_taxes()
+
+ def test_country_tag_from_spain(self):
+ """
+ This test ensure that xml_id from `account.account.tag` in the EU_TAG_MAP are processed correctly by the oss
+ tax creation mechanism.
+ """
+ # get an eu country which isn't the current one:
+ another_eu_country_code = (self.env.ref('base.europe').country_ids - self.company_data['company'].country_id)[0].code
+ tax_oss = self.env['account.tax'].search([('name', 'ilike', f'%{another_eu_country_code}%')], limit=1)
+
+ for doc_type, tag_xml_id in (
+ ("invoice", "l10n_es.mod_303_124"),
+ ):
+ with self.subTest(doc_type=doc_type, report_line_xml_id=tag_xml_id):
+ oss_tag_id = tax_oss[f"{doc_type}_repartition_line_ids"]\
+ .filtered(lambda x: x.repartition_type == 'base')\
+ .tag_ids
+
+ expected_tag_id = self.env.ref(tag_xml_id)
+
+ self.assertIn(expected_tag_id, oss_tag_id, f"{doc_type} tag from Spanish CoA not correctly linked")
+
+
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSUSA(AccountTestInvoicingCommon):
@@ -58,7 +99,6 @@ class TestOSSUSA(AccountTestInvoicingCommon):
self.assertFalse(len(tax_oss), "OSS tax shouldn't be instanced on a US company")
-
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSMap(AccountTestInvoicingCommon):