Skip to content

Commit c9ecc9d

Browse files
committed
[17.0][FIX] intrastat_product: set the correct country code for Greece
Check correct country code for Greece. The correct is EL instead of GR.
1 parent adb5f1f commit c9ecc9d

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

intrastat_product/models/intrastat_product_declaration.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
_logger = logging.getLogger(__name__)
1717

1818

19+
SRC_DEST_COUNTRY_CODE_MAPPING = {
20+
"GB": "XI",
21+
"GR": "EL",
22+
}
23+
24+
PRODUCT_ORIGIN_COUNTRY_CODE_MAPPING = {
25+
"GB": "XU",
26+
"GR": "EL",
27+
}
28+
29+
1930
class IntrastatProductDeclaration(models.Model):
2031
_name = "intrastat.product.declaration"
2132
_description = "Intrastat Product Declaration"
@@ -1105,8 +1116,7 @@ def _compute_region_code(self):
11051116
def _compute_src_dest_country_code(self):
11061117
for this in self:
11071118
code = this.src_dest_country_id and this.src_dest_country_id.code or False
1108-
if code == "GB":
1109-
code = "XI" # Northern Ireland
1119+
code = SRC_DEST_COUNTRY_CODE_MAPPING.get(code, code)
11101120
this.src_dest_country_code = code
11111121

11121122
@api.depends("product_origin_country_id")
@@ -1117,10 +1127,7 @@ def _compute_product_origin_country_code(self):
11171127
and this.product_origin_country_id.code
11181128
or False
11191129
)
1120-
if code == "GB":
1121-
code = "XU"
1122-
# XU can be used when you don't know if the product
1123-
# originate from Great-Britain or from Northern Ireland
1130+
code = PRODUCT_ORIGIN_COUNTRY_CODE_MAPPING.get(code, code)
11241131
this.product_origin_country_code = code
11251132

11261133
@api.constrains("vat")

intrastat_product/tests/test_intrastat_product.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ def test_declaration_manual_lines(self):
9696
declaration_line = declaration_line_form.save()
9797
self.assertEqual(declaration_line.src_dest_country_code, "FR")
9898

99+
# Test Greece country code conversion
100+
computation_line_form.src_dest_country_id = self.env.ref("base.gr")
101+
declaration_line_form_greece = Form(
102+
self.env["intrastat.product.computation.line"].with_context(
103+
default_parent_id=self.declaration.id
104+
)
105+
)
106+
declaration_line_form_greece = declaration_line_form.save()
107+
self.assertEqual(declaration_line_form_greece.src_dest_country_code, "EL")
108+
99109
def test_declaration_no_country(self):
100110
self.demo_company.country_id = False
101111
with self.assertRaises(ValidationError):

0 commit comments

Comments
 (0)