[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 <jco@odoo.com>
This commit is contained in:
dbkosky
2022-02-18 10:46:47 +00:00
committed by dbkosky
parent 276cc1d647
commit 1906584e02
2 changed files with 2 additions and 2 deletions
@@ -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
@@ -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