mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[13.0][MIG] - report_substitute migration
This commit is contained in:
@@ -6,30 +6,29 @@ from odoo import api, models
|
||||
|
||||
class MailComposeMessage(models.TransientModel):
|
||||
|
||||
_inherit = 'mail.compose.message'
|
||||
_inherit = "mail.compose.message"
|
||||
|
||||
@api.multi
|
||||
@api.onchange('template_id')
|
||||
@api.onchange("template_id")
|
||||
def onchange_template_id_wrapper(self):
|
||||
if self.template_id:
|
||||
report_template = self.template_id.report_template
|
||||
active_ids = []
|
||||
if self.env.context.get('active_ids'):
|
||||
active_ids = self.env.context.get('active_ids')
|
||||
elif self.env.context.get('default_res_id'):
|
||||
active_ids = [self.env.context.get('default_res_id')]
|
||||
if self.env.context.get("active_ids"):
|
||||
active_ids = self.env.context.get("active_ids")
|
||||
elif self.env.context.get("default_res_id"):
|
||||
active_ids = [self.env.context.get("default_res_id")]
|
||||
if (
|
||||
report_template
|
||||
and report_template.action_report_substitution_rule_ids
|
||||
and active_ids
|
||||
):
|
||||
old_report_template = report_template
|
||||
self.template_id.report_template = (
|
||||
old_report_template.get_substitution_report(active_ids)
|
||||
old_tmpl = report_template
|
||||
self.template_id.report_template = old_tmpl.get_substitution_report(
|
||||
active_ids
|
||||
)
|
||||
onchange_result_with_substituted_report = (
|
||||
super().onchange_template_id_wrapper()
|
||||
)
|
||||
self.template_id.report_template = old_report_template
|
||||
self.template_id.report_template = old_tmpl
|
||||
return onchange_result_with_substituted_report
|
||||
return super().onchange_template_id_wrapper()
|
||||
|
||||
Reference in New Issue
Block a user