[FIX] email_template: use valid email_from content
Correctly use the email_from tag from template.
This partially reverts commit 0f82346167
.
"[FIX] email_template: keep email_from and outgoing server"
Remove the email_from part that was incorrect, keeping the one on mail_server_id
Instead of assigning an non-evaulated email_from in the context, specify the
email_from in the onchange method. This way the created email has an evaulated
from value. This was an issue for templates using email_from like
"${(object.user_id.email or '')|safe}"
In the _notify method method, the email_from is partially respected as it will
be used a fallback only. However changing that would introduce a modification of
behaviour not suitable for 7.0 branch.
Fixes #8409
This commit is contained in:
parent
bbd15cdca6
commit
909e6e300a
|
@ -76,8 +76,6 @@ class mail_compose_message(osv.TransientModel):
|
|||
# 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:
|
||||
|
@ -91,7 +89,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
""" - mass_mailing: we cannot render, so return the template values
|
||||
- normal mode: return rendered values """
|
||||
if template_id and composition_mode == 'mass_mail':
|
||||
values = self.pool.get('email.template').read(cr, uid, template_id, ['subject', 'body_html', 'attachment_ids'], context)
|
||||
values = self.pool.get('email.template').read(cr, uid, template_id, ['subject', 'body_html', 'attachment_ids', 'email_from'], context)
|
||||
values.pop('id')
|
||||
elif template_id:
|
||||
values = self.generate_email_for_composer(cr, uid, template_id, res_id, context=context)
|
||||
|
@ -110,7 +108,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
}
|
||||
values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
|
||||
else:
|
||||
values = self.default_get(cr, uid, ['body', 'subject', 'partner_ids', 'attachment_ids'], context=context)
|
||||
values = self.default_get(cr, uid, ['body', 'subject', 'partner_ids', 'attachment_ids', 'email_from'], context=context)
|
||||
|
||||
if values.get('body_html'):
|
||||
values['body'] = values.pop('body_html')
|
||||
|
@ -148,7 +146,7 @@ class mail_compose_message(osv.TransientModel):
|
|||
mail.compose.message, transform email_cc and email_to into partner_ids """
|
||||
template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context)
|
||||
# filter template values
|
||||
fields = ['body_html', 'subject', 'email_to', 'email_recipients', 'email_cc', 'attachment_ids', 'attachments']
|
||||
fields = ['body_html', 'subject', 'email_to', 'email_recipients', 'email_cc', 'attachment_ids', 'attachments', 'email_from']
|
||||
values = dict((field, template_values[field]) for field in fields if template_values.get(field))
|
||||
values['body'] = values.pop('body_html', '')
|
||||
|
||||
|
|
|
@ -156,10 +156,7 @@ 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 '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:
|
||||
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:
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue