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.

23 lines
856 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015-2017 Compassion CH (http://www.compassion.ch)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from odoo import models, api
  5. class EmailTemplatePreview(models.TransientModel):
  6. """ Put the preview inside sendgrid template """
  7. _inherit = 'email_template.preview'
  8. @api.onchange('res_id')
  9. @api.multi
  10. def on_change_res_id(self):
  11. result = super(EmailTemplatePreview, self).on_change_res_id()
  12. body_html = self.body_html
  13. template_id = self.env.context.get('template_id')
  14. template = self.env['mail.template'].browse(template_id)
  15. sendgrid_template = template.sendgrid_localized_template
  16. if sendgrid_template:
  17. self.body_html = sendgrid_template.html_content.replace(
  18. '<%body%>', body_html)
  19. return result