[FIX] account_edi: send payment xml in "Send receipt by email" action

With MX edi company setup
Create an invoice, validate cfdi
Register payment, validate cfdi
Action > Send receipt by email

Issue: payment xml is missing from email composer

opw-3289582

closes odoo/odoo#123168

X-original-commit: ed6c3c3a4a6c5c685e709734c536a5e4252b4eb8
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2023-06-06 10:30:00 +02:00
parent ad72ee0cbb
commit ce28cb2683
@@ -13,3 +13,18 @@ class AccountPayment(models.Model):
def action_retry_edi_documents_error(self):
self.ensure_one()
return self.move_id.action_retry_edi_documents_error()
####################################################
# Mailing
####################################################
def _process_attachments_for_template_post(self, mail_template):
""" Add Edi attachments to templates. """
result = super()._process_attachments_for_template_post(mail_template)
for payment in self.filtered('edi_document_ids'):
payment_result = result.setdefault(payment.id, {})
for edi_doc in payment.edi_document_ids:
edi_attachments = edi_doc._filter_edi_attachments_for_mailing()
payment_result.setdefault('attachment_ids', []).extend(edi_attachments.get('attachment_ids', []))
payment_result.setdefault('attachments', []).extend(edi_attachments.get('attachments', []))
return result