[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:
committed by
Laurent Smet
parent
a78bba1214
commit
bbf4fb625b
@@ -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
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
from . import models
|
||||
from . import tools
|
||||
from . import wizard
|
||||
|
||||
|
||||
def _l10n_it_edi_update_export_tax(env):
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user