mirror of https://github.com/OCA/social.git
[FIX] email_template_qweb: get translations working
Translations were broken, things hav changed in 14.0 and we need to call `_classify_per_lang` method to get the right lang, and use it to render the content.pull/1072/head
parent
d5655dc6ad
commit
00e58b8ae2
|
@ -21,19 +21,27 @@ class MailTemplate(models.Model):
|
||||||
res_ids = [res_ids]
|
res_ids = [res_ids]
|
||||||
multi_mode = False
|
multi_mode = False
|
||||||
result = super(MailTemplate, self).generate_email(res_ids, fields=fields)
|
result = super(MailTemplate, self).generate_email(res_ids, fields=fields)
|
||||||
for res_id in res_ids:
|
for lang, (_template, _template_res_ids) in self._classify_per_lang(
|
||||||
if self.body_type == "qweb" and (not fields or "body_html" in fields):
|
res_ids
|
||||||
for record in self.env[self.model].browse(res_id):
|
).items():
|
||||||
body_html = self.body_view_id._render(
|
self_with_lang = self.with_context(lang=lang)
|
||||||
{"object": record, "email_template": self}
|
for res_id in res_ids:
|
||||||
)
|
if self.body_type == "qweb" and (not fields or "body_html" in fields):
|
||||||
# Some wizards, like when sending a sales order, need this
|
for record in self_with_lang.env[self.model].browse(res_id):
|
||||||
# fix to display accents correctly
|
body_html = self_with_lang.body_view_id._render(
|
||||||
body_html = tools.ustr(body_html)
|
{"object": record, "email_template": self_with_lang}
|
||||||
result[res_id]["body_html"] = self._render_template_postprocess(
|
)
|
||||||
{res_id: body_html}
|
# Some wizards, like when sending a sales order, need this
|
||||||
)[res_id]
|
# fix to display accents correctly
|
||||||
result[res_id]["body"] = tools.html_sanitize(
|
body_html = tools.ustr(body_html)
|
||||||
result[res_id]["body_html"]
|
result[res_id][
|
||||||
)
|
"body_html"
|
||||||
|
] = self_with_lang._render_template_postprocess(
|
||||||
|
{res_id: body_html}
|
||||||
|
)[
|
||||||
|
res_id
|
||||||
|
]
|
||||||
|
result[res_id]["body"] = tools.html_sanitize(
|
||||||
|
result[res_id]["body_html"]
|
||||||
|
)
|
||||||
return result if multi_mode else result[res_ids[0]]
|
return result if multi_mode else result[res_ids[0]]
|
||||||
|
|
Loading…
Reference in New Issue