diff --git a/mail_debrand/models/__init__.py b/mail_debrand/models/__init__.py index c385ac4..0e99243 100644 --- a/mail_debrand/models/__init__.py +++ b/mail_debrand/models/__init__.py @@ -1 +1 @@ -from . import mail_render_mixin +from . import mail_render_mixinANDmail_mail diff --git a/mail_debrand/models/mail_render_mixin.py b/mail_debrand/models/mail_render_mixin.py deleted file mode 100644 index 20a97f5..0000000 --- a/mail_debrand/models/mail_render_mixin.py +++ /dev/null @@ -1,78 +0,0 @@ -# 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 - -from odoo import api, models - - -class MailRenderMixin(models.AbstractModel): - _inherit = "mail.render.mixin" - - @api.model - def _render_template( - self, - template_src, - model, - res_ids, - engine="jinja", - add_context=None, - post_process=False, - ): - """replace anything that is with odoo in templates - if is a + 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 " + odoo_word + r"", "", html) - if powered_by not in html: - return html - root = htmltree.fromstring(html) - powered_by_elements = root.xpath("//*[text()[contains(.,'%s')]]" % powered_by) - for elem in powered_by_elements: - # make sure it isn't a spurious powered by - if any( - [ - "www.odoo.com" in child.get("href", "") - for child in elem.getchildren() - ] - ): - for child in elem.getchildren(): - elem.remove(child) - elem.text = None - return htmltree.tostring(root).decode("utf-8") - - @api.model - def render_post_process(self, html): - html = super().render_post_process(html) - return self._debrand_body(html) diff --git a/mail_debrand/models/mail_thread.py b/mail_debrand/models/mail_thread.py deleted file mode 100644 index 7fc6f0a..0000000 --- a/mail_debrand/models/mail_thread.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2019 Eficent Business and IT Consulting Services S.L. -# Lois Rilo -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models - - -class MailThread(models.AbstractModel): - _inherit = "mail.thread" - - def _replace_local_links(self, html, base_url=None): - html = super()._replace_local_links(html, base_url=base_url) - html_debranded = self.env["mail.template"]._debrand_body(html) - return html_debranded