Skip to content

Commit

Permalink
[FIX] mass_mailing: markup usage
Browse files Browse the repository at this point in the history
- using a string to join `Markup`s is useless, that just strips out
  the `Markup`
- the entire toplevel `Markup` can be formatted in one shot

closes odoo#140428

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
  • Loading branch information
xmo-odoo committed Oct 31, 2023
1 parent d786992 commit 090b721
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions addons/mass_mailing/models/mailing_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,15 @@ def _update_subscription_from_email(self, email, opt_out=True, force_message=Non
if force_message:
body = force_message
elif opt_out:
body = Markup('<p>%s</p>') % _(
'%(contact_name)s unsubscribed from the following mailing list(s)',
contact_name=contact.display_name
body = Markup('<p>%s</p><ul>%s</ul>') % (
_('%(contact_name)s unsubscribed from the following mailing list(s)', contact_name=contact.display_name),
Markup().join(Markup('<li>%s</li>') % name for name in updated.mapped('name')),
)
body += Markup('<ul>%s</ul>' % ''.join(Markup('<li>%s</li>') % name for name in updated.mapped('name')))
else:
body = Markup('<p>%s</p>') % _(
'%(contact_name)s subscribed to the following mailing list(s)',
contact_name=contact.display_name
body = Markup('<p>%s</p><ul>%s</ul>') % (
_('%(contact_name)s subscribed to the following mailing list(s)', contact_name=contact.display_name),
Markup().join(Markup('<li>%s</li>') % name for name in updated.mapped('name')),
)
body += Markup('<ul>%s</ul>' % ''.join(Markup('<li>%s</li>') % name for name in updated.mapped('name')))
contact.with_context(mail_create_nosubscribe=True).message_post(
body=body,
subtype_id=self.env['ir.model.data']._xmlid_to_res_id('mail.mt_note'),
Expand Down

0 comments on commit 090b721

Please sign in to comment.