# Copyright 2019 O4SB - Graeme Gellatly # Copyright 2019 Tecnativa - Ernesto Tejeda # Copyright 2020 Onestein - Andrea Stirpe # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import re from lxml import etree, html from odoo import api, models class MailRenderMixin(models.AbstractModel): _inherit = "mail.render.mixin" def remove_href_odoo(self, value, remove_parent=True, remove_before=False): if len(value) < 20: return value has_odoo_link = re.search(r" bytes_text = etree.tostring( previous, pretty_print=True, method="html" ) only_what_is_in_tags = bytes_text[: bytes_text.rfind(b">") + 1] data_formatted = html.fromstring(only_what_is_in_tags) parent.replace(previous, data_formatted) if parent.getparent() and remove_parent: # anchor