[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) <las@odoo.com>
Signed-off-by: Aliya Tastemirova (alta) <alta@odoo.com>
This commit is contained in:
aliya
2024-02-21 12:59:09 +00:00
parent 0a06734556
commit 40b0ac6690
2 changed files with 8 additions and 7 deletions
+2 -2
View File
@@ -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
@@ -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,