From 9f7d2c697a83d9bbdb74504d9746c19d8165b9e2 Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Mon, 20 Aug 2012 10:19:11 +0200 Subject: [PATCH] [FIX] mail: improved render_template context preparation - rename '_pre_render_template' to '_prepare_render_template_context' - _preare_render_template_context return a new context, which is distinct from original method context - as we want to control more precisely what context will be available to render_template(). bzr revid: xal@openerp.com-20120820081911-34h2zlzcrspfpyz6 --- addons/mail/wizard/mail_compose_message.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index ed10f0f0c34..53632bfbada 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -216,14 +216,14 @@ class mail_compose_message(osv.osv_memory): active_ids = active_model_pool.search(cr, uid, ast.literal_eval(mail.filter_id.domain), context=ast.literal_eval(mail.filter_id.context)) for active_id in active_ids: - self._pre_render_template(cr, uid, active_model, active_id, context) - subject = self.render_template(cr, uid, mail.subject, active_model, active_id, context) - rendered_body = self.render_template(cr, uid, body, active_model, active_id, context) - email_from = self.render_template(cr, uid, mail.email_from, active_model, active_id, context) - email_to = self.render_template(cr, uid, mail.email_to, active_model, active_id, context) - email_cc = self.render_template(cr, uid, mail.email_cc, active_model, active_id, context) - email_bcc = self.render_template(cr, uid, mail.email_bcc, active_model, active_id, context) - reply_to = self.render_template(cr, uid, mail.reply_to, active_model, active_id, context) + render_context = self._prepare_render_template_context(cr, uid, active_model, active_id, context) + subject = self.render_template(cr, uid, mail.subject, active_model, active_id, render_context) + rendered_body = self.render_template(cr, uid, body, active_model, active_id, render_context) + email_from = self.render_template(cr, uid, mail.email_from, active_model, active_id, render_context) + email_to = self.render_template(cr, uid, mail.email_to, active_model, active_id, render_context) + email_cc = self.render_template(cr, uid, mail.email_cc, active_model, active_id, render_context) + email_bcc = self.render_template(cr, uid, mail.email_bcc, active_model, active_id, render_context) + reply_to = self.render_template(cr, uid, mail.reply_to, active_model, active_id, render_context) # in mass-mailing mode we only schedule the mail for sending, it will be # processed as soon as the mail scheduler runs. @@ -242,8 +242,8 @@ class mail_compose_message(osv.osv_memory): return {'type': 'ir.actions.act_window_close'} - def _pre_render_template(self, cr, uid, active_model, active_id, context): - return True + def _prepare_render_template_context(self, cr, uid, active_model, active_id, context): + return {} def render_template(self, cr, uid, template, model, res_id, context=None): """Render the given template text, replace mako-like expressions ``${expr}``