diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 22bb53beae3..d9b5f5fe6ba 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -66,10 +66,18 @@ class mail_compose_message(osv.TransientModel): Indeed, basic mail.compose.message wizard duplicates attachments in mass mailing mode. But in 'single post' mode, attachments of an email template also have to be duplicated to avoid changing their ownership. """ + email_context = dict(context or {}) for wizard in self.browse(cr, uid, ids, context=context): if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id: continue template = self.pool.get('email.template').browse(cr, uid, wizard.template_id, context=context) + # TODO v8, remove me + # template specific outgoing mail server and email from is lost in super send_mail + # store them in the context to avoid falling back to default values + if template.mail_server_id: + email_context['mail_server_id'] = template.mail_server_id.id + if template.email_from: + email_context['email_from'] = template.email_from new_attachment_ids = [] for attachment in wizard.attachment_ids: if attachment in template.attachment_ids: @@ -77,7 +85,7 @@ class mail_compose_message(osv.TransientModel): else: new_attachment_ids.append(attachment.id) self.write(cr, uid, wizard.id, {'attachment_ids': [(6, 0, new_attachment_ids)]}, context=context) - return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) + return super(mail_compose_message, self).send_mail(cr, uid, ids, context=email_context) def onchange_template_id(self, cr, uid, ids, template_id, composition_mode, model, res_id, context=None): """ - mass_mailing: we cannot render, so return the template values diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index f4c74b0c996..29bd64ef5fa 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -156,7 +156,10 @@ class mail_notification(osv.Model): body_html = tools.append_content_to_html(body_html, signature, plaintext=True, container_tag='div') # email_from: partner-user alias or partner email or mail.message email_from - if msg.author_id and msg.author_id.user_ids and msg.author_id.user_ids[0].alias_domain and msg.author_id.user_ids[0].alias_name: + if 'email_from' in context: + # temporary workaround for mail from send mail wizard + email_from = context['email_from'] + elif msg.author_id and msg.author_id.user_ids and msg.author_id.user_ids[0].alias_domain and msg.author_id.user_ids[0].alias_name: email_from = formataddr((msg.author_id.name, '%s@%s' % (msg.author_id.user_ids[0].alias_name, msg.author_id.user_ids[0].alias_domain))) elif msg.author_id: email_from = formataddr((msg.author_id.name, msg.author_id.email)) @@ -174,6 +177,9 @@ class mail_notification(osv.Model): 'email_from': email_from, 'references': references, } + if 'mail_server_id' in context: + # temporary workaround for mail from send mail wizard + mail_values['mail_server_id'] = context['mail_server_id'] email_notif_id = mail_mail.create(cr, uid, mail_values, context=context) try: return mail_mail.send(cr, uid, [email_notif_id], recipient_ids=notify_partner_ids, context=context)