Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
dhongu committed Sep 17, 2023
1 parent 8ab24b1 commit 2190ff5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions l10n_ro_intrastat_xml/tests/test_intrastat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_invoice_purchase(self):
# a facut onchange ?
self.assertEqual(invoice.intrastat_country_id, country)

wizard = Form(self.env["l10n_ro_intrastat.intrastat_xml_declaration"])
wizard = Form(self.env["l10n.ro.intrastat.xml.declaration"])
wizard.contact_id = self.env.user.partner_id
wizard = wizard.save()
wizard.create_xml()
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_invoice_sale(self):
invoice = invoice.save()
invoice.post()

wizard = Form(self.env["l10n_ro_intrastat.intrastat_xml_declaration"])
wizard = Form(self.env["l10n.ro.intrastat.xml.declaration"])
wizard.contact_id = self.env.user.partner_id
wizard.type = "dispatches"
wizard = wizard.save()
Expand All @@ -101,7 +101,7 @@ def test_error(self):
invoice = invoice.save()
invoice.post()

wizard = Form(self.env["l10n_ro_intrastat.intrastat_xml_declaration"])
wizard = Form(self.env["l10n.ro.intrastat.xml.declaration"])
wizard.contact_id = self.env.user.partner_id
wizard = wizard.save()

Expand Down
14 changes: 13 additions & 1 deletion l10n_ro_intrastat_xml/wizard/intrastat_xml_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def _get_def_year(self):
file_save = fields.Binary("Intrastat Report File", readonly=True)
state = fields.Selection([("draft", "Draft"), ("download", "Download")], string="State", default="draft")
cn8 = fields.Char("CN8", size=4, required=True, default="2022")
enterprise = fields.Boolean("Enterprise", default=False, compute="_compute_enterprise")

def _compute_enterprise(self):
for rec in self:
rec.enterprise = self.env["ir.module.module"].search(
[("name", "=", "account_intrastat"), ("state", "=", "installed")]
)

def _company_warning(self, translated_msg):
"""
Expand Down Expand Up @@ -249,7 +256,12 @@ def _get_lines(self, decl_datas, dispatchmode, decl):
TrCodeA = intrastat_transaction.code
TrCodeB = ""

ModeOfTransport = invoice.transport_mode_id.code or company.transport_mode_id.code or False
if self.enterprise:
ModeOfTransport = (
invoice.intrastat_transport_mode_id.code or company.intrastat_transport_mode_id.code or False
)
else:
ModeOfTransport = invoice.transport_mode_id.code or company.transport_mode_id.code or False

if not ModeOfTransport:
raise UserError(_("Invoice %s without Transport Mode") % invoice.name)
Expand Down

0 comments on commit 2190ff5

Please sign in to comment.