From 1906584e022450746ebd79bc050e2e3d363f4642 Mon Sep 17 00:00:00 2001 From: dbkosky Date: Thu, 17 Feb 2022 09:16:04 +0000 Subject: [PATCH] [FIX] l10n_it_edi: import fattura pa expected singleton product error Sometimes when importing products that share the same internal reference code (default_code) the _import_fattura_pa function will throw an expected singleton error. This is because, in order to find the product for the line of the invoice, it will search for the product reference code (e.g. [CONS_0001]), which is not necessarily unique. I've set the limit to one on the search to fix the immediate error for now, but I will add more logic to better search for the relevant product in a future commit. closes odoo/odoo#84826 Task-id: 2764978 X-original-commit: aae609915cb1f76c32c518ff8959674853633f55 Signed-off-by: Josse Colpaert --- addons/l10n_it_edi/models/account_edi_format.py | 2 +- addons/l10n_it_edi_sdicoop/models/account_edi_format.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/l10n_it_edi/models/account_edi_format.py b/addons/l10n_it_edi/models/account_edi_format.py index f51a416188e..2bd0ffd1baa 100644 --- a/addons/l10n_it_edi/models/account_edi_format.py +++ b/addons/l10n_it_edi/models/account_edi_format.py @@ -482,7 +482,7 @@ class AccountEdiFormat(models.Model): if not invoice_line_form.product_id: for element_code in elements_code: code = element_code.xpath('.//CodiceValore')[0] - product = self.env['product.product'].search([('default_code', '=', code.text)]) + product = self.env['product.product'].search([('default_code', '=', code.text)], limit=1) if product: invoice_line_form.product_id = product break diff --git a/addons/l10n_it_edi_sdicoop/models/account_edi_format.py b/addons/l10n_it_edi_sdicoop/models/account_edi_format.py index f327bb6f853..12214365379 100644 --- a/addons/l10n_it_edi_sdicoop/models/account_edi_format.py +++ b/addons/l10n_it_edi_sdicoop/models/account_edi_format.py @@ -3,7 +3,7 @@ from odoo import models, _, _lt from odoo.exceptions import UserError -from odoo.addons.account_edi_proxy_client.models.account_edi_proxy_user import AccountEdiProxyError, DEFAULT_SERVER_URL, DEFAULT_TEST_SERVER_URL +from odoo.addons.account_edi_proxy_client.models.account_edi_proxy_user import AccountEdiProxyError from lxml import etree import base64