From 04bfbb4e7e02d6a1e04725d9e9e83a1084809068 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 21 Apr 2023 11:23:15 +0000 Subject: [PATCH] [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 --- addons/account_edi/__init__.py | 1 + addons/account_edi/wizard/__init__.py | 3 +++ .../account_edi/wizard/account_move_send.py | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 addons/account_edi/wizard/__init__.py create mode 100644 addons/account_edi/wizard/account_move_send.py diff --git a/addons/account_edi/__init__.py b/addons/account_edi/__init__.py index 75da1c3431e..3a7dfde6acb 100644 --- a/addons/account_edi/__init__.py +++ b/addons/account_edi/__init__.py @@ -2,3 +2,4 @@ from . import models from . import controller +from . import wizard diff --git a/addons/account_edi/wizard/__init__.py b/addons/account_edi/wizard/__init__.py new file mode 100644 index 00000000000..2d5a5a51c88 --- /dev/null +++ b/addons/account_edi/wizard/__init__.py @@ -0,0 +1,3 @@ +# -*- encoding: utf-8 -*- + +from . import account_move_send diff --git a/addons/account_edi/wizard/account_move_send.py b/addons/account_edi/wizard/account_move_send.py new file mode 100644 index 00000000000..ccb26b42de9 --- /dev/null +++ b/addons/account_edi/wizard/account_move_send.py @@ -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