Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,30 @@ def _group_line_hashcode_fields(self):
res["partner_vat"] = self.partner_vat
return res

@api.depends("src_dest_country_id")
def _compute_src_dest_country_code(self):
res = super()._compute_src_dest_country_code()
for record in self.filtered(lambda rec: rec.src_dest_country_id):
code = record.src_dest_country_code
iso_code = record.partner_id._map_aeat_country_iso_code(
record.src_dest_country_id
)
if iso_code and iso_code != code:
record.src_dest_country_code = iso_code
return res

@api.depends("product_origin_country_id")
def _compute_product_origin_country_code(self):
res = super()._compute_product_origin_country_code()
for record in self.filtered(lambda rec: rec.product_origin_country_id):
code = record.product_origin_country_code
iso_code = record.partner_id._map_aeat_country_iso_code(
record.product_origin_country_id
)
if iso_code and iso_code != code:
record.product_origin_country_code = iso_code
return res


class IntrastatProductDeclarationLine(models.Model):
_inherit = "intrastat.product.declaration.line"
Expand Down
14 changes: 14 additions & 0 deletions l10n_es_intrastat_report/tests/test_l10n_es_intrastat_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,17 @@ def test_report_creation_arrivals(self):
items = line.split(";")
self.assertTrue(items[0] in ("PT", "FR"))
self.assertEqual(items[6], self.hs_code.local_code)

def test_intrastat_greece_declaration(self):
"""Test that intrastat declaration for Greece works as expected."""
partner_greece = self.env["res.partner"].create(
{"name": "Test Partner Greece", "country_id": self.env.ref("base.gr").id}
)
invoice = self._create_invoice_for_intrastat(
"out_invoice", partner_greece, self.fiscal_position_b2b
)
report_dispatches = self._create_declaration("dispatches")
report_dispatches.action_gather()
computation_lines = report_dispatches.computation_line_ids
self.assertIn(invoice.id, computation_lines.mapped("invoice_id").ids)
self.assertIn("EL", computation_lines.mapped("src_dest_country_code"))