summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/models/mail_template.py')
-rw-r--r--addons/mail/models/mail_template.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py
index d3363a8fd72..0e8e2cc855f 100644
--- a/addons/mail/models/mail_template.py
+++ b/addons/mail/models/mail_template.py
@@ -261,9 +261,16 @@ class MailTemplate(models.Model):
_logger.warning('QWeb template %s not found when sending template %s. Sending without layouting.' % (notif_layout, self.name))
else:
record = self.env[self.model].browse(res_id)
+ model = self.env['ir.model']._get(record._name)
+
+ if self.lang:
+ lang = self._render_lang([res_id])[res_id]
+ template = template.with_context(lang=lang)
+ model = model.with_context(lang=lang)
+
template_ctx = {
'message': self.env['mail.message'].sudo().new(dict(body=values['body_html'], record_name=record.display_name)),
- 'model_description': self.env['ir.model']._get(record._name).display_name,
+ 'model_description': model.display_name,
'company': 'company_id' in record and record['company_id'] or self.env.company,
'record': record,
}