# Copyright 2019 O4SB - Graeme Gellatly # Copyright 2019 Tecnativa - Ernesto Tejeda # Copyright 2020 Onestein - Andrea Stirpe # Copyright 2021 Tecnativa - João Marques # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import re from lxml import etree, html from markupsafe import Markup from odoo import api, models, tools class MailRenderMixin(models.AbstractModel): _inherit = "mail.render.mixin" def remove_href_odoo(self, value, remove_parent=True, to_keep=None): if len(value) < 20: return value # value can be bytes type; ensure we get a proper string if type(value) is bytes: back_to_bytes = True value = value.decode() else: back_to_bytes = False has_dev_odoo_link = re.search( r"") tree = html.fromstring(value) odoo_anchors = tree.xpath('//a[contains(@href,"odoo.com")]') for elem in odoo_anchors: parent = elem.getparent() if remove_parent and parent.getparent() is not None: # anchor ", to_keep) if back_to_bytes: value = value.encode() return value @api.model def _render_template( self, template_src, model, res_ids, engine="inline_template", add_context=None, options=None, post_process=False, ): """replace anything that is with odoo in templates if is a )""", "
 
", message ) return wrapper(message)