From 3c763e47a9164df254e24fe54b56c4fb312dfbc3 Mon Sep 17 00:00:00 2001 From: "John Laterre (jol)" Date: Fri, 7 Jan 2022 11:35:48 +0000 Subject: [PATCH] [FIX] account_edi_ubl: check counterpart based on move_type Currently, when importing an invoice/credit note, it is assumed that it is a vendor (bill/credit note). But it is not always the case (accounting firms for example). This is why the counterpart is now adapted based on the move_type. opw-2697984 closes odoo/odoo#82495 X-original-commit: 8a7d41c99ec493d86166708552c8df51eaa268c2 Signed-off-by: Laurent Smet Signed-off-by: John Laterre --- addons/account_edi_ubl/models/account_edi_format.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/account_edi_ubl/models/account_edi_format.py b/addons/account_edi_ubl/models/account_edi_format.py index 6e3182e82a8..1c89345307f 100644 --- a/addons/account_edi_ubl/models/account_edi_format.py +++ b/addons/account_edi_ubl/models/account_edi_format.py @@ -98,11 +98,12 @@ class AccountEdiFormat(models.Model): invoice_form.invoice_incoterm_id = self.env['account.incoterms'].search([('code', '=', elements[0].text)], limit=1) # Partner + counterpart = 'Customer' if invoice_form.move_type in ('out_invoice', 'out_refund') else 'Supplier' invoice_form.partner_id = self._retrieve_partner( - name=_find_value('//cac:AccountingSupplierParty/cac:Party//cbc:Name'), - phone=_find_value('//cac:AccountingSupplierParty/cac:Party//cbc:Telephone'), - mail=_find_value('//cac:AccountingSupplierParty/cac:Party//cbc:ElectronicMail'), - vat=_find_value('//cac:AccountingSupplierParty/cac:Party//cbc:CompanyID'), + name=_find_value(f'//cac:Accounting{counterpart}Party/cac:Party//cbc:Name'), + phone=_find_value(f'//cac:Accounting{counterpart}Party/cac:Party//cbc:Telephone'), + mail=_find_value(f'//cac:Accounting{counterpart}Party/cac:Party//cbc:ElectronicMail'), + vat=_find_value(f'//cac:Accounting{counterpart}Party/cac:Party//cbc:CompanyID'), ) # Lines