diff --git a/intrastat_product/__manifest__.py b/intrastat_product/__manifest__.py
index 6abbcb4..3a31c30 100644
--- a/intrastat_product/__manifest__.py
+++ b/intrastat_product/__manifest__.py
@@ -7,11 +7,11 @@
{
"name": "Intrastat Product",
- "version": "13.0.1.0.3",
+ "version": "13.0.1.1.0",
"category": "Intrastat",
"license": "AGPL-3",
"summary": "Base module for Intrastat Product",
- "author": "brain-tec AG, Akretion, Noviat, " "Odoo Community Association (OCA)",
+ "author": "brain-tec AG, Akretion, Noviat, Odoo Community Association (OCA)",
"depends": [
"intrastat_base",
"product_harmonized_system",
diff --git a/intrastat_product/models/account_move.py b/intrastat_product/models/account_move.py
index 5576b0a..d81ed54 100644
--- a/intrastat_product/models/account_move.py
+++ b/intrastat_product/models/account_move.py
@@ -67,9 +67,16 @@ class AccountMoveLine(models.Model):
hs_code_id = fields.Many2one(
comodel_name="hs.code", string="Intrastat Code", ondelete="restrict"
)
+ weight = fields.Integer(string="Weight", help="Net weight in Kg")
+ product_origin_country_id = fields.Many2one(
+ comodel_name="res.country",
+ string="Country of Origin",
+ help="Country of origin of the product i.e. product " "'made in ____'.",
+ )
@api.onchange("product_id")
def intrastat_product_id_change(self):
if self.product_id:
- hs_code = self.product_id.get_hs_code_recursively()
- self.hs_code_id = hs_code and hs_code.id or False
+ self.hs_code_id = self.product_id.get_hs_code_recursively()
+ self.product_origin_country_id = self.product_id.origin_country_id
+ self.weight = self.product_id.weight
diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py
index 4535b78..8b4c3cf 100644
--- a/intrastat_product/models/intrastat_product_declaration.py
+++ b/intrastat_product/models/intrastat_product_declaration.py
@@ -272,6 +272,20 @@ class IntrastatProductDeclaration(models.Model):
pce_uom = self._get_uom_refs("pce_uom")
weight = suppl_unit_qty = 0.0
+ if not product:
+ weight = inv_line.weight
+ if not weight:
+ note = "\n" + _(
+ "Missing weight on invoice %s, line with intrastat code %s."
+ ) % (inv_line.move_id.name, inv_line.hs_code_id.local_code)
+ note += "\n" + _(
+ "Please correct the product record and regenerate "
+ "the lines or adjust the impacted lines manually"
+ )
+ self._note += note
+ return weight, suppl_unit_qty
+ return weight, suppl_unit_qty
+
if not source_uom:
note = "\n" + _(
"Missing unit of measure on the line with %d "
@@ -435,7 +449,9 @@ class IntrastatProductDeclaration(models.Model):
return incoterm
def _get_product_origin_country(self, inv_line):
- return inv_line.product_id.origin_country_id
+ return (
+ inv_line.product_origin_country_id or inv_line.product_id.origin_country_id
+ )
def _update_computation_line_vals(self, inv_line, line_vals):
""" placeholder for localization modules """
diff --git a/intrastat_product/views/account_move.xml b/intrastat_product/views/account_move.xml
index d1d51da..7254b8e 100644
--- a/intrastat_product/views/account_move.xml
+++ b/intrastat_product/views/account_move.xml
@@ -24,12 +24,16 @@
position="after"
>
+
+
+
+