From 8dbf3aab020f3c094808f30d6893392239eec37e Mon Sep 17 00:00:00 2001 From: Alfredo Zamora Date: Fri, 23 Apr 2021 12:02:34 +0200 Subject: [PATCH] force round to 1 additional_units field only if has a value --- .../models/intrastat_statement_purchase_section.py | 5 ++++- .../models/intrastat_statement_sale_section.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py index cf21a693c5b3..05c66c294aee 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_purchase_section.py @@ -148,10 +148,13 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None): statement_id.company_id or company_id, dp_model.precision_get('Account')) + # check if additional_units has a value + has_additional_units = bool(inv_intra_line.additional_units) res.update({ 'transaction_nature_id': transaction_nature_id.id, 'weight_kg': round(inv_intra_line.weight_kg) or 1, - 'additional_units': round(inv_intra_line.additional_units) or 1, + 'additional_units': round(inv_intra_line.additional_units) or ( + 0 if not has_additional_units else 1), 'statistic_amount_euro': statistic_amount, 'delivery_code_id': delivery_code_id.id, 'transport_code_id': transport_code_id.id, diff --git a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py index 6fc2eec9a7af..0eab98d39987 100644 --- a/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py +++ b/l10n_it_intrastat_statement/models/intrastat_statement_sale_section.py @@ -112,10 +112,13 @@ def _prepare_statement_line(self, inv_intra_line, statement_id=None): statement_id.company_id or company_id, dp_model.precision_get('Account')) + # check if additional_units has a value + has_additional_units = bool(inv_intra_line.additional_units) res.update({ 'transaction_nature_id': transaction_nature_id.id, 'weight_kg': round(inv_intra_line.weight_kg) or 1, - 'additional_units': round(inv_intra_line.additional_units) or 1, + 'additional_units': round(inv_intra_line.additional_units) or ( + 0 if not has_additional_units else 1), 'statistic_amount_euro': statistic_amount, 'delivery_code_id': delivery_code_id.id, 'transport_code_id': transport_code_id.id,