[FIX] account_edi: we forgot to add the edi documents in the mail send wizard

The send and mail wizard was replaced by something simpler, but we
forgot to automatically attach the attachments of the edi documents
of the old account_edi in the mail.

Before, the XML of e.g. the Mexican EDI, generated when the invoice gets
sent (and signed) by the government,  would not be included
automatically when the user wants to send the invoice by mail to the
client. Now, it will be.

closes odoo/odoo#119435

X-original-commit: b3cbd7ea2b6cc07efd9a6358bd37f23f1ba4e6ab
Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
Josse Colpaert
2023-04-27 11:21:12 +02:00
parent 894090914e
commit 04bfbb4e7e
3 changed files with 27 additions and 0 deletions
+1
View File
@@ -2,3 +2,4 @@
from . import models
from . import controller
from . import wizard
+3
View File
@@ -0,0 +1,3 @@
# -*- encoding: utf-8 -*-
from . import account_move_send
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from odoo import models
class AccountMoveSend(models.Model):
_inherit = 'account.move.send'
def _get_default_mail_attachments_data(self, mail_template, move):
""" Returns all the placeholder data and mail template data
"""
results = super()._get_default_mail_attachments_data(mail_template, move)
for doc in move.edi_document_ids:
attachment_sudo = doc.sudo().attachment_id
if attachment_sudo.res_model and attachment_sudo.res_id:
results.append({
'id': attachment_sudo.id,
'name': attachment_sudo.name,
'mimetype': attachment_sudo.mimetype,
'placeholder': False,
})
return results