From a8d8046cf20b2698286370a9a037e4d706755d81 Mon Sep 17 00:00:00 2001 From: Jignesh Rathod Date: Tue, 24 Mar 2015 10:18:16 +0100 Subject: [PATCH] [IMP] mail: mail_template: instead of crashing when sending email based on templates that have a void email_from, just fall back on the default email_from defined on the mail_message model. --- addons/mail/mail_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_template.py b/addons/mail/mail_template.py index f73ed0cffcd..cbe309b83ff 100644 --- a/addons/mail/mail_template.py +++ b/addons/mail/mail_template.py @@ -551,11 +551,12 @@ class mail_template(osv.osv): # create a mail_mail based on values, without attachments values = self.generate_email(cr, uid, template_id, res_id, context=context) - if not values.get('email_from'): - raise UserError(_("Sender email is missing or empty after template rendering. Specify one to deliver your message")) values['recipient_ids'] = [(4, pid) for pid in values.get('partner_ids', list())] attachment_ids = values.pop('attachment_ids', []) attachments = values.pop('attachments', []) + # add a protection against void email_from + if 'email_from' in values and not values.get('email_from'): + values.pop('email_from') msg_id = mail_mail.create(cr, uid, values, context=context) mail = mail_mail.browse(cr, uid, msg_id, context=context)