diff --git a/addons/account_edi/wizard/account_move_send.py b/addons/account_edi/wizard/account_move_send.py index ccb26b42de9..ca4ff9cffd0 100644 --- a/addons/account_edi/wizard/account_move_send.py +++ b/addons/account_edi/wizard/account_move_send.py @@ -6,18 +6,20 @@ from odoo import models class AccountMoveSend(models.Model): _inherit = 'account.move.send' + def _get_mail_attachment_from_doc(self, doc): + attachment_sudo = doc.sudo().attachment_id + if attachment_sudo.res_model and attachment_sudo.res_id: + return [{ + 'id': attachment_sudo.id, + 'name': attachment_sudo.name, + 'mimetype': attachment_sudo.mimetype, + 'placeholder': False, + }] + 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, - }) + results += self._get_mail_attachment_from_doc(doc) return results diff --git a/addons/l10n_it_edi/__init__.py b/addons/l10n_it_edi/__init__.py index 344d6aa0f88..aed50688be0 100644 --- a/addons/l10n_it_edi/__init__.py +++ b/addons/l10n_it_edi/__init__.py @@ -3,6 +3,7 @@ from . import models from . import tools +from . import wizard def _l10n_it_edi_update_export_tax(env): diff --git a/addons/l10n_it_edi/wizard/__init__.py b/addons/l10n_it_edi/wizard/__init__.py new file mode 100644 index 00000000000..30c60877ea7 --- /dev/null +++ b/addons/l10n_it_edi/wizard/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import account_move_send diff --git a/addons/l10n_it_edi/wizard/account_move_send.py b/addons/l10n_it_edi/wizard/account_move_send.py new file mode 100644 index 00000000000..31076ba4662 --- /dev/null +++ b/addons/l10n_it_edi/wizard/account_move_send.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +from odoo import models + + +class AccountMoveSend(models.Model): + _inherit = 'account.move.send' + + def _get_mail_attachment_from_doc(self, doc): + if doc.edi_format_id.code == 'fattura_pa': + return [] + return super()._get_mail_attachment_from_doc(doc)