sbejaoui
5 years ago
9 changed files with 97 additions and 17 deletions
-
1report_substitute/__init__.py
-
2report_substitute/__manifest__.py
-
1report_substitute/models/__init__.py
-
35report_substitute/models/ir_actions_report.py
-
24report_substitute/models/mail_thread.py
-
16report_substitute/static/src/js/action_manager.js
-
6report_substitute/views/ir_actions_report.xml
-
1report_substitute/wizards/__init__.py
-
28report_substitute/wizards/mail_compose_message.py
@ -1,2 +1,3 @@ |
|||
from . import models |
|||
from . import wizards |
|||
from . import tests |
@ -1,2 +1,3 @@ |
|||
from . import ir_actions_report |
|||
from . import ir_actions_report_substitution_rule |
|||
from . import mail_thread |
@ -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 |
@ -0,0 +1 @@ |
|||
from . import mail_compose_message |
@ -0,0 +1,28 @@ |
|||
# Copyright 2019 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from odoo import api, models |
|||
|
|||
|
|||
class MailComposeMessage(models.TransientModel): |
|||
|
|||
_inherit = 'mail.compose.message' |
|||
|
|||
@api.multi |
|||
@api.onchange('template_id') |
|||
def onchange_template_id_wrapper(self): |
|||
old_report_template = False |
|||
if ( |
|||
self.template_id |
|||
and self.template_id.report_template |
|||
and self.env.context.get('active_ids') |
|||
): |
|||
active_ids = self.env.context.get('active_ids') |
|||
old_report_template = self.template_id.report_template |
|||
self.template_id.report_template = ( |
|||
old_report_template.get_substitution_report(active_ids) |
|||
) |
|||
res = super().onchange_template_id_wrapper() |
|||
if old_report_template: |
|||
self.template_id.report_template = old_report_template |
|||
return res |
Write
Preview
Loading…
Cancel
Save
Reference in new issue