Skip to content

Commit f54d1b5

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 f54d1b5

2 files changed

Lines changed: 38 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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ 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 = Form(
101+
self.env["intrastat.product.computation.line"].with_context(
102+
default_parent_id=self.declaration.id
103+
)
104+
)
105+
computation_line_form.src_dest_country_id = self.env.ref("base.gr")
106+
computation_line_form.transaction_id = self.transaction
107+
computation_line_form.hs_code_id = self.hs_code_computer
108+
computation_line_form.region_code = "ZZ"
109+
computation_line_form.product_origin_country_code = "BE"
110+
computation_line_form.transport_id = self.env.ref(
111+
"intrastat_product.intrastat_transport_3"
112+
)
113+
computation_line = computation_line_form.save()
114+
self.assertEqual(computation_line.src_dest_country_code, "EL")
115+
declaration_line_form = Form(
116+
self.env["intrastat.product.declaration.line"].with_context(
117+
default_parent_id=self.declaration.id
118+
)
119+
)
120+
declaration_line_form.src_dest_country_code = "EL"
121+
declaration_line = declaration_line_form.save()
122+
self.assertEqual(declaration_line.src_dest_country_code, "EL")
123+
99124
def test_declaration_no_country(self):
100125
self.demo_company.country_id = False
101126
with self.assertRaises(ValidationError):

0 commit comments

Comments
 (0)