[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user