From ce28cb268309dd2d5cfba1e36f7541aa3bdac93a Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 9 May 2023 09:42:46 +0000 Subject: [PATCH] [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 Signed-off-by: Grazioso Andrea (agr) --- addons/account_edi/models/account_payment.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/addons/account_edi/models/account_payment.py b/addons/account_edi/models/account_payment.py index ce746c91705..851f44b365d 100644 --- a/addons/account_edi/models/account_payment.py +++ b/addons/account_edi/models/account_payment.py @@ -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