[FIX] mail: avoid crash when sending emails if no notification layout is found

If no email layout is found when trying to render the layout around the
message content, just send body in notification emails instead of
crashing. See notably 89051058f4 .

Related to task 1943901
Linked to PR #32404
This commit is contained in:
Xavier-Do
2019-05-29 13:34:32 +00:00
committed by Thibault Delavallée
parent 7a6269719f
commit b4e9b3fb45
+6 -2
View File
@@ -2072,7 +2072,12 @@ class MailThread(models.AbstractModel):
for group_tpl_values in [group for group in recipients.values() if group['recipients']]:
# generate notification email content
template_ctx = {**base_template_ctx, **group_tpl_values}
mail_body = base_template.render(template_ctx, engine='ir.qweb', minimal_qcontext=True)
# {company, is_discussion, lang, message, model_description, record, record_name, signature, subtype, tracking_values, website_url}
# {actions, button_access, has_button_access, recipients}
if base_template:
mail_body = base_template.render(template_ctx, engine='ir.qweb', minimal_qcontext=True)
else:
mail_body = message.body
mail_body = self.env['mail.thread']._replace_local_links(mail_body)
mail_subject = message.subject or (message.record_name and 'Re: %s' % message.record_name)
@@ -2221,7 +2226,6 @@ class MailThread(models.AbstractModel):
recipient_data['channels'].append({'id': cid, 'notif': notif, 'type': ctype})
return recipient_data
@api.model
def _notify_encode_link(self, base_link, params):
secret = self.env['ir.config_parameter'].sudo().get_param('database.secret')