diff --git a/l10n_fr_intrastat_product/models/intrastat_product_declaration.py b/l10n_fr_intrastat_product/models/intrastat_product_declaration.py index 1ac58bac3..b343b8fb7 100644 --- a/l10n_fr_intrastat_product/models/intrastat_product_declaration.py +++ b/l10n_fr_intrastat_product/models/intrastat_product_declaration.py @@ -102,6 +102,8 @@ def _get_fr_department(self, inv_line, notedict): def _generate_xml(self): """Generate the INSTAT XML file export.""" + if self.company_id.country_id.code != "FR": + return super()._generate_xml() my_company_vat = self.company_id.partner_id.vat.replace(" ", "") if not self.company_id.siret: @@ -125,13 +127,15 @@ def _generate_xml(self): envelope = etree.SubElement(root, "Envelope") envelope_id = etree.SubElement(envelope, "envelopeId") if not self.company_id.fr_intrastat_accreditation: - raise UserError( - _( - "The customs accreditation identifier is not set " - "for the company '%s'." + self.message_post( + body=_( + "No XML file generated because the Customs Accreditation " + "Identifier is not set on the accounting configuration " + "page of the company '%s'." ) % self.company_id.display_name ) + return envelope_id.text = self.company_id.fr_intrastat_accreditation create_date_time = etree.SubElement(envelope, "DateTime") create_date = etree.SubElement(create_date_time, "date") diff --git a/l10n_fr_intrastat_service/tests/test_fr_intrastat_service.py b/l10n_fr_intrastat_service/tests/test_fr_intrastat_service.py index 7fa3547fe..01058d09a 100644 --- a/l10n_fr_intrastat_service/tests/test_fr_intrastat_service.py +++ b/l10n_fr_intrastat_service/tests/test_fr_intrastat_service.py @@ -8,15 +8,14 @@ from dateutil.relativedelta import relativedelta from lxml import etree +from odoo.exceptions import UserError from odoo.tests import tagged from odoo.tests.common import SavepointCase from odoo.tools import float_compare -from odoo.exceptions import UserError @tagged("post_install", "-at_install") class TestFrIntrastatService(SavepointCase): - @classmethod def setUpClass(cls): super().setUpClass()