Files
odoo_source/addons/mass_mailing/models/mail_render_mixin.py
T
Sébastien Mottet (oms) ac0579263b [IMP] mass_mailing: add 'view in browser' link in mailings
PURPOSE

Add a block that allows recipients to check the email in a browser in case
their mail service provider does not render it well or to see it full screen.

SPECIFICATIONS

A thumbnail has been added in the snippet thumbnails list of the mail editor.
It allows to add an header snippet. This snippet contains a link allowing the
recipient to see the mail in its browser instead of its mail client.

Add a route to display a mailing content. This route should be recipient
dependent as mailings could contain jinja markers. Using the same access token
and check as unsubscribe route this public route allows to display a mailing
content directly rendered for a given customer.

_get_unsubscribe_url method is moved from mail_mail to mailing as it does
not really belong to the mail model. Indeed it is mailing dependent.

A view URL leading to the view in browser route is added. It is managed like
the unsubscribe url: magically avoid shortening, magically rewrite when
sending email.

Task ID-2239327
PR #49886
2020-08-05 13:55:04 +00:00

24 lines
812 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class MailRenderMixin(models.AbstractModel):
_inherit = "mail.render.mixin"
@api.model
def _render_template_postprocess(self, rendered):
# super will transform relative url to absolute
rendered = super(MailRenderMixin, self)._render_template_postprocess(rendered)
# apply shortener after
if self.env.context.get('post_convert_links'):
for res_id, html in rendered.items():
rendered[res_id] = self._shorten_links(
html,
self.env.context['post_convert_links'],
blacklist=['/unsubscribe_from_list', '/view']
)
return rendered