[FIX] account_edi_ubl_cii,l10n_it_edi: fix import for invisible fields

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) <wan@odoo.com>
This commit is contained in:
Julien Van Roy
2022-07-18 18:41:14 +02:00
parent 499a694fe7
commit ffabf28360
4 changed files with 4 additions and 4 deletions
@@ -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
@@ -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)
@@ -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)
@@ -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: