[FIX] intrastat_product - set region_code based on code or the region

This commit is contained in:
Jérémy Didderen
2023-11-13 14:17:11 +01:00
parent aed1246741
commit 24f07ef680
2 changed files with 4 additions and 4 deletions

View File

@@ -411,7 +411,7 @@ class IntrastatProductDeclaration(models.Model):
If none found, get the company's default intrastat region.
"""
region = False
region = self.env["intrastat.region"]
move_type = inv_line.move_id.move_type
if move_type in ("in_invoice", "in_refund"):
po_line = self.env["purchase.order.line"].search(
@@ -691,7 +691,7 @@ class IntrastatProductDeclaration(models.Model):
)
region_code = self._get_region_code(inv_line, notedict)
region = False
region = self.env["intrastat.region"]
if not region_code:
region = self._get_region(inv_line, notedict)
@@ -709,7 +709,7 @@ class IntrastatProductDeclaration(models.Model):
"amount_accessory_cost_company_currency": 0.0,
"transaction_id": intrastat_transaction.id,
"product_origin_country_id": product_origin_country.id or False,
"region_code": region_code,
"region_code": region_code or region.code,
"region_id": region and region.id or False,
"partner_id": partner.id,
}

View File

@@ -24,4 +24,4 @@ class StockLocation(models.Model):
)
if warehouse:
return warehouse.region_id
return None
return self.env["intrastat.region"]