OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.2 KiB

  1. # Copyright 2019 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, models
  4. class MailComposeMessage(models.TransientModel):
  5. _inherit = 'mail.compose.message'
  6. @api.multi
  7. @api.onchange('template_id')
  8. def onchange_template_id_wrapper(self):
  9. if self.template_id:
  10. report_template = self.template_id.report_template
  11. if (
  12. report_template
  13. and report_template.action_report_substitution_rule_ids
  14. and self.env.context.get('active_ids')
  15. ):
  16. active_ids = self.env.context.get('active_ids')
  17. old_report_template = report_template
  18. self.template_id.report_template = (
  19. old_report_template.get_substitution_report(active_ids)
  20. )
  21. onchange_result_with_substituted_report = (
  22. super().onchange_template_id_wrapper()
  23. )
  24. self.template_id.report_template = old_report_template
  25. return onchange_result_with_substituted_report
  26. return super().onchange_template_id_wrapper()