From ffabf28360e429fbfd34f7b5514e62384d45dcb4 Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Mon, 18 Jul 2022 09:25:55 +0000 Subject: [PATCH] [FIX] account_edi_ubl_cii,l10n_it_edi: fix import for invisible fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The import of EDI documents is broken since it's no longer possible to write on invisible fields. Add checks before assigning product_uom_id or currency_id. See https://github.com/odoo/odoo/commit/5ccc32fcf72cbfb6bb077d99a7657416c502aac1 closes odoo/odoo#95842 Signed-off-by: William André (wan) --- addons/account_edi_ubl_cii/models/account_edi_common.py | 2 +- .../account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py | 2 +- addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py | 2 +- addons/l10n_it_edi/models/account_edi_format.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account_edi_ubl_cii/models/account_edi_common.py b/addons/account_edi_ubl_cii/models/account_edi_common.py index ce830396e3e..7f55f40559c 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_common.py +++ b/addons/account_edi_ubl_cii/models/account_edi_common.py @@ -503,7 +503,7 @@ class AccountEdiCommon(models.AbstractModel): # quantity invoice_line_form.quantity = billed_qty * qty_factor - if product_uom_id is not None: + if product_uom_id is not None and not invoice_line_form._get_modifier('product_uom_id', 'invisible'): invoice_line_form.product_uom_id = product_uom_id # price_unit diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py index 6b0b63ce445..c1217c279a6 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py @@ -225,7 +225,7 @@ class AccountEdiXmlCII(models.AbstractModel): # ==== currency_id ==== currency_code_node = tree.find('.//{*}InvoiceCurrencyCode') - if currency_code_node is not None: + if currency_code_node is not None and self.env.user.has_group('base.group_multi_currency'): currency = self.env['res.currency'].with_context(active_test=False).search([ ('name', '=', currency_code_node.text), ], limit=1) diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py index 913249524e0..a469d4be491 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py @@ -476,7 +476,7 @@ class AccountEdiXmlUBL20(models.AbstractModel): # ==== currency_id ==== currency_code_node = tree.find('.//{*}DocumentCurrencyCode') - if currency_code_node is not None: + if currency_code_node is not None and self.env.user.has_group('base.group_multi_currency'): currency = self.env['res.currency'].with_context(active_test=False).search([ ('name', '=', currency_code_node.text), ], limit=1) diff --git a/addons/l10n_it_edi/models/account_edi_format.py b/addons/l10n_it_edi/models/account_edi_format.py index 6eb45e700a1..2042fb8a6bb 100644 --- a/addons/l10n_it_edi/models/account_edi_format.py +++ b/addons/l10n_it_edi/models/account_edi_format.py @@ -471,7 +471,7 @@ class AccountEdiFormat(models.Model): # Currency. <2.1.1.2> elements = body_tree.xpath('.//DatiGeneraliDocumento/Divisa') - if elements: + if elements and self.env.user.has_group('base.group_multi_currency'): currency_str = elements[0].text currency = self.env.ref('base.%s' % currency_str.upper(), raise_if_not_found=False) if currency != self.env.company.currency_id and currency.active: