diff options
| author | Denis Ledoux <dle@odoo.com> | 2014-12-11 14:11:33 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2014-12-11 14:11:33 +0100 |
| commit | a6212d2d206adb44de28ebd8a5194069bbbef2ae (patch) | |
| tree | 98a5219095c356c8deea2d93d74dbc663ada28de /addons/email_template | |
| parent | d347e9c28cf6ef617f68ef08212b61d8c244af42 (diff) | |
| parent | e11d1c2b7ac37d03c4567355dc007a7e414c08ae (diff) | |
[MERGE] forward port of branch saas-3 up to e11d1c2
Diffstat (limited to 'addons/email_template')
| -rw-r--r-- | addons/email_template/email_template.py | 11 | ||||
| -rw-r--r-- | addons/email_template/wizard/mail_compose_message.py | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index ba9bd263e31..dea832c7a44 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -471,11 +471,14 @@ class email_template(osv.osv): results = dict() for template, template_res_ids in templates_to_res_ids.iteritems(): # generate fields value for all res_ids linked to the current template + ctx = context.copy() + if template.lang: + ctx['lang'] = template._context.get('lang') for field in fields: generated_field_values = self.render_template_batch( cr, uid, getattr(template, field), template.model, template_res_ids, post_process=(field == 'body_html'), - context=context) + context=ctx) for res_id, field_value in generated_field_values.iteritems(): results.setdefault(res_id, dict())[field] = field_value # compute recipients @@ -503,13 +506,9 @@ class email_template(osv.osv): if template.report_template: for res_id in template_res_ids: attachments = [] - report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context) + report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=ctx) report = report_xml_pool.browse(cr, uid, template.report_template.id, context) report_service = report.report_name - # Ensure report is rendered using template's language - ctx = context.copy() - if template.lang: - ctx['lang'] = self.render_template_batch(cr, uid, template.lang, template.model, [res_id], context)[res_id] # take 0 ? if report.report_type in ['qweb-html', 'qweb-pdf']: result, format = self.pool['report'].get_pdf(cr, uid, [res_id], report_service, context=ctx), 'pdf' diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 14cdecd89c6..1a5a915dfe2 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -129,7 +129,7 @@ class mail_compose_message(osv.TransientModel): email_template = self.pool.get('email.template') ir_model_pool = self.pool.get('ir.model') for record in self.browse(cr, uid, ids, context=context): - model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model)], context=context) + model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model or 'mail.message')], context=context) model_id = model_ids and model_ids[0] or False model_name = '' if model_id: |
