Skip to content
Snippets Groups Projects
Commit fe995449 authored by Brice bib Bartoletti's avatar Brice bib Bartoletti
Browse files

[FIX] l10n_eu_service: fix l10n_es test skipping


The aim of this commit is to improve the test skipping code of the oss modules
by avoiding to hardcode the chart_template_ref (xml_id) directly in the error
message.

Before this commit:
The TestOSSSpain test class was failing when the l10n_es module wasn't
installed instead of being skipped.

After this commit:
The TestOSSSpain test class is correctly skipped instead of failing.

closes odoo/odoo#102551

Signed-off-by: default avatarQuentin De Paoli <qdp@odoo.com>
parent 062fb69f
No related branches found
No related tags found
No related merge requests found
......@@ -5,20 +5,27 @@ from odoo.addons.account.tests.common import AccountTestInvoicingCommon
from odoo.tests import tagged
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSBelgium(AccountTestInvoicingCommon):
class OssTemplateTestCase(AccountTestInvoicingCommon):
@classmethod
def setUpClass(self, chart_template_ref='l10n_be.l10nbe_chart_template'):
def load_specific_chart_template(cls, chart_template_ref):
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_be.l10nbe_chart_template":
self.skipTest(self, reason="Belgian CoA is required for this testSuite but l10n_be isn't installed")
if e.args[0] == f"External ID not found in the system: {chart_template_ref}":
cls.skipTest(cls, reason=f"The {chart_template_ref} CoA is required for this testSuite but the corresponding localization module isn't installed")
else:
raise e
self.company_data['company'].country_id = self.env.ref('base.be')
self.company_data['company']._map_eu_taxes()
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSBelgium(OssTemplateTestCase):
@classmethod
def setUpClass(cls, chart_template_ref='l10n_be.l10nbe_chart_template'):
cls.load_specific_chart_template(chart_template_ref)
cls.company_data['company'].country_id = cls.env.ref('base.be')
cls.company_data['company']._map_eu_taxes()
def test_country_tag_from_belgium(self):
"""
......@@ -46,17 +53,11 @@ class TestOSSBelgium(AccountTestInvoicingCommon):
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSSpain(AccountTestInvoicingCommon):
class TestOSSSpain(OssTemplateTestCase):
@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.load_specific_chart_template(chart_template_ref)
cls.company_data['company'].country_id = cls.env.ref('base.es')
cls.company_data['company']._map_eu_taxes()
......@@ -83,13 +84,13 @@ class TestOSSSpain(AccountTestInvoicingCommon):
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSUSA(AccountTestInvoicingCommon):
class TestOSSUSA(OssTemplateTestCase):
@classmethod
def setUpClass(self, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
self.company_data['company'].country_id = self.env.ref('base.us')
self.company_data['company']._map_eu_taxes()
def setUpClass(cls, chart_template_ref=None):
cls.load_specific_chart_template(chart_template_ref)
cls.company_data['company'].country_id = cls.env.ref('base.us')
cls.company_data['company']._map_eu_taxes()
def test_no_oss_tax(self):
# get an eu country which isn't the current one:
......@@ -100,7 +101,7 @@ class TestOSSUSA(AccountTestInvoicingCommon):
@tagged('post_install', 'post_install_l10n', '-at_install')
class TestOSSMap(AccountTestInvoicingCommon):
class TestOSSMap(OssTemplateTestCase):
def test_oss_eu_tag_map(self):
""" Checks that the xml_id referenced in the map are correct.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment