From b4e9b3fb45fc9816d178e4664156889a386175c5 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 12 Apr 2019 14:45:18 +0000 Subject: [PATCH] [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 89051058f4ab7069024f7f6cf2caac05bd68b499 . Related to task 1943901 Linked to PR #32404 --- addons/mail/models/mail_thread.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 7dbb9d4ef4b..98e9c29ce97 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -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')