File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
1930class 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" )
Original file line number Diff line number Diff 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 ):
You can’t perform that action at this time.
0 commit comments