[IMP] account_edi: refactor method to override mail attachments in localizations

closes odoo/odoo#122187

X-original-commit: 8d815adb0254256aa707d8c5568330adf25d83c1
Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
Josse Colpaert
2023-05-24 14:28:12 +02:00
committed by Laurent Smet
parent a78bba1214
commit bbf4fb625b
4 changed files with 26 additions and 9 deletions
+11 -9
View File
@@ -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
+1
View File
@@ -3,6 +3,7 @@
from . import models
from . import tools
from . import wizard
def _l10n_it_edi_update_export_tax(env):
+2
View File
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import account_move_send
@@ -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)