From 64e1bf798e3c94116f014c83a1376bb488225d18 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 10 Nov 2023 19:09:17 +0100 Subject: [PATCH] intrastat_product: suppl_unit_qty rounded to 1 if between 0 and 0.5 Improve comment in the code about rounding --- intrastat_product/models/intrastat_product_declaration.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index 2b1604c..85b79c5 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -1149,11 +1149,16 @@ class IntrastatProductComputationLine(models.Model): computation_line["amount_company_currency"] + computation_line["amount_accessory_cost_company_currency"] ) - # round, otherwise odoo with truncate (6.7 -> 6... instead of 7 !) + # on computation lines, weight and suppl_unit_qty are floats + # on declaration lines, weight and suppl_unit_qty are integer => so we must round() for field in fields_to_sum: vals[field] = int(round(vals[field])) + # the intrastat specs say that, if the value is between 0 and 0.5, + # it should be rounded to 1 if not vals["weight"]: vals["weight"] = 1 + if vals["intrastat_unit_id"] and not vals["suppl_unit_qty"]: + vals["suppl_unit_qty"] = 1 vals["amount_company_currency"] = int(round(vals["amount_company_currency"])) return vals