summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorRavi Gohil <rgo@openerp.com>2014-11-17 17:06:37 +0530
committerMartin Trigaux <mat@odoo.com>2014-12-10 15:56:57 +0100
commitb035cfb7e9df10dcdcfdf371946aa77057e5393c (patch)
treed63af42af1f170fa7330ab8f76ead2a3b66dfea8 /addons
parent9f9e7ef0e1ca1d2f5fc5e0a166499c95359dbbf3 (diff)
[FIX] email_template: missing translations in email template
When composing an email based on an email template, some parts of the template (the result of name_get on fields) were not translated. This was due to missing language in context when rendering the template. Fixes #3708, opw 617309
Diffstat (limited to 'addons')
-rw-r--r--addons/email_template/email_template.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index c5e24b0da5f..e5ea9a5bb83 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -311,11 +311,14 @@ class email_template(osv.osv):
context = {}
report_xml_pool = self.pool.get('ir.actions.report.xml')
template = self.get_email_template(cr, uid, template_id, res_id, context)
+ ctx = context.copy()
+ if template.lang:
+ ctx['lang'] = template._context.get('lang')
values = {}
for field in ['subject', 'body_html', 'email_from',
'email_to', 'email_recipients', 'email_cc', 'reply_to']:
values[field] = self.render_template(cr, uid, getattr(template, field),
- template.model, res_id, context=context) \
+ template.model, res_id, context=ctx) \
or False
if template.user_signature:
signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature
@@ -333,12 +336,9 @@ class email_template(osv.osv):
attachments = []
# Add report in attachments
if template.report_template:
- 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_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name
# Ensure report is rendered using template's language
- ctx = context.copy()
- if template.lang:
- ctx['lang'] = self.render_template(cr, uid, template.lang, template.model, res_id, context)
service = netsvc.LocalService(report_service)
(result, format) = service.create(cr, uid, [res_id], {'model': template.model}, ctx)
# TODO in trunk, change return format to binary to match message_post expected format