From 40b0ac669035b74b95d92aa99e5d11293dff5cb1 Mon Sep 17 00:00:00 2001 From: aliya Date: Wed, 21 Feb 2024 10:30:25 +0100 Subject: [PATCH] [FIX] account_peppol: check commercial partner instead of partner When checking a partner's validity on Peppol network, we should always check the `commercial_partner_id` to get the right eas & endpoint. Also, the Peppol verification check should not occur if the current company does not have an active peppol registration. Currently, if a user wants to send an invoice to a specific contact of a partner, they cannot as `_need_ubl_cii_xml` evaluates to False because the contact is not a valid Peppol participant. opw-3748720 closes odoo/odoo#152654 closes odoo/odoo#154823 Signed-off-by: Laurent Smet (las) Signed-off-by: Aliya Tastemirova (alta) --- addons/account_peppol/models/account_move.py | 4 ++-- addons/account_peppol/wizard/account_move_send.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/account_peppol/models/account_move.py b/addons/account_peppol/models/account_move.py index ef5a68a6f2f..c5a2a4454b6 100644 --- a/addons/account_peppol/models/account_move.py +++ b/addons/account_peppol/models/account_move.py @@ -42,8 +42,8 @@ class AccountMove(models.Model): self.ensure_one() res = super()._need_ubl_cii_xml() - partner = self.partner_id - if partner.ubl_cii_format in {False, 'facturx', 'oioubl_201'}: + partner = self.partner_id.commercial_partner_id + if partner.ubl_cii_format in {False, 'facturx', 'oioubl_201'} or self.company_id.account_peppol_proxy_state != 'active': return res if not partner.peppol_eas or not partner.peppol_endpoint: return False diff --git a/addons/account_peppol/wizard/account_move_send.py b/addons/account_peppol/wizard/account_move_send.py index 6a99a676c35..65e2d9f270e 100644 --- a/addons/account_peppol/wizard/account_move_send.py +++ b/addons/account_peppol/wizard/account_move_send.py @@ -54,7 +54,7 @@ class AccountMoveSend(models.TransientModel): @api.depends('move_ids') def _compute_peppol_warning(self): for wizard in self: - invalid_partners = wizard.move_ids.partner_id.filtered( + invalid_partners = wizard.move_ids.partner_id.commercial_partner_id.filtered( lambda partner: not partner.account_peppol_is_endpoint_valid) if not invalid_partners: wizard.peppol_warning = False @@ -69,7 +69,7 @@ class AccountMoveSend(models.TransientModel): for wizard in self: # show peppol option if either the ubl option is available or any move already has a ubl file generated # and moves are not processing/done and if partners have an edi format set to one that works for peppol - invalid_partners = wizard.move_ids.partner_id.filtered( + invalid_partners = wizard.move_ids.partner_id.commercial_partner_id.filtered( lambda partner: partner.ubl_cii_format in {False, 'facturx', 'oioubl_201'}) wizard.enable_peppol = ( wizard.company_id.account_peppol_proxy_state == 'active' \ @@ -136,18 +136,19 @@ class AccountMoveSend(models.TransientModel): invoice.peppol_move_state = 'skipped' continue - if not invoice.partner_id.peppol_eas or not invoice.partner_id.peppol_endpoint: + partner = invoice.partner_id.commercial_partner_id + if not partner.peppol_eas or not partner.peppol_endpoint: # should never happen but in case it does, we need to handle it invoice.peppol_move_state = 'error' invoice_data['error'] = _('The partner is missing Peppol EAS and/or Endpoint identifier.') continue - if not invoice.partner_id.account_peppol_is_endpoint_valid: + if not partner.account_peppol_is_endpoint_valid: invoice.peppol_move_state = 'error' invoice_data['error'] = _('Please verify partner configuration in partner settings.') continue - receiver_identification = f"{invoice.partner_id.peppol_eas}:{invoice.partner_id.peppol_endpoint}" + receiver_identification = f"{partner.peppol_eas}:{partner.peppol_endpoint}" params['documents'].append({ 'filename': filename, 'receiver': receiver_identification,