Skip to content

Commit

Permalink
l10n_fr_intrastat_product: call super on _generate_xml
Browse files Browse the repository at this point in the history
_generate_xml() : Don't raise if company_id.fr_intrastat_accreditation
is not set, to avoid blocking draft->done
  • Loading branch information
alexis-via committed Sep 9, 2024
1 parent e371375 commit ca3ae67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 <b>Customs Accreditation "
"Identifier</b> 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")
Expand Down
3 changes: 1 addition & 2 deletions l10n_fr_intrastat_service/tests/test_fr_intrastat_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ca3ae67

Please sign in to comment.