[FW][FIX] mail: Give reply-to non-template value
When sending a mass mail through the composer, if the field ``reply_to`` had to
fall back to being ``email_from``, reply_to would take the value of the template
syntax instead of the rendered value.
This is notably the case when mass-mailing invoices through the accounting app.
Resulting in reply_to fields such as: '{{user.email}}'
On some mail clients (including mailhog), this could also result in template
syntax being shown as part of the subject or sender field.
This commit fixes that by correctly taking the rendered value of 'email_from'
Task-2816845
X-original-commit: e320b852e8f1958ac3dccaa5333420bb7b8d8f3d
Part-of: odoo/odoo#98287
This commit is contained in:
committed by
Thibault Delavallée
parent
fe0107803e
commit
00c04b7a8f
@@ -369,7 +369,11 @@ class MailComposer(models.TransientModel):
|
||||
reply_to_value = dict.fromkeys(res_ids, None)
|
||||
if mass_mail_mode and not self.reply_to_force_new:
|
||||
records = self.env[self.model].browse(res_ids)
|
||||
reply_to_value = records._notify_get_reply_to(default=self.email_from)
|
||||
reply_to_value = records._notify_get_reply_to(default=False)
|
||||
# when having no specific reply-to, fetch rendered email_from value
|
||||
for res_id, reply_to in reply_to_value.items():
|
||||
if not reply_to:
|
||||
reply_to_value[res_id] = rendered_values.get(res_id, {}).get('email_from', False)
|
||||
|
||||
for res_id in res_ids:
|
||||
# static wizard (mail.message) values
|
||||
|
||||
@@ -1090,7 +1090,6 @@ class TestComposerResultsMass(TestMailComposer):
|
||||
'body_content': 'TemplateBody %s' % record.name,
|
||||
'email_from': self.partner_employee_2.email_formatted,
|
||||
'subject': 'TemplateSubject %s' % record.name,
|
||||
|
||||
},
|
||||
fields_values={
|
||||
'email_from': self.partner_employee_2.email_formatted,
|
||||
@@ -1129,11 +1128,11 @@ class TestComposerResultsMass(TestMailComposer):
|
||||
author=self.partner_employee,
|
||||
email_values={
|
||||
'email_from': self.partner_employee_2.email_formatted,
|
||||
# 'reply_to': self.partner_employee_2.email_formatted, FIXME: currently failing (unrendered jinja)
|
||||
'reply_to': self.partner_employee_2.email_formatted,
|
||||
},
|
||||
fields_values={
|
||||
'email_from': self.partner_employee_2.email_formatted,
|
||||
# 'reply_to': self.partner_employee_2.email_formatted, # FIXME: currently failing (unrendered jinja)
|
||||
'reply_to': self.partner_employee_2.email_formatted,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user