mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] - manage substitution for mail.thread message_post_with_template
This commit is contained in:
24
report_substitute/models/mail_thread.py
Normal file
24
report_substitute/models/mail_thread.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright 2019 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class MailThread(models.AbstractModel):
|
||||
|
||||
_inherit = 'mail.thread'
|
||||
|
||||
@api.multi
|
||||
def message_post_with_template(self, template_id, **kwargs):
|
||||
template = self.env['mail.template'].browse(template_id)
|
||||
old_report = False
|
||||
if template and template.report_template and self.ids:
|
||||
active_ids = self.ids
|
||||
old_report = template.report_template
|
||||
template.report_template = old_report.get_substitution_report(
|
||||
active_ids
|
||||
)
|
||||
res = super().message_post_with_template(template_id, **kwargs)
|
||||
if old_report:
|
||||
template.report_template = old_report
|
||||
return res
|
||||
Reference in New Issue
Block a user