From aa00a0209710464e3862fe18d6fbd12ee0c2d42b Mon Sep 17 00:00:00 2001 From: Ioan Galan Date: Thu, 22 Jul 2021 13:19:23 +0200 Subject: [PATCH] [IMP] mail_debrand: Split code into model-specific files --- mail_debrand/models/__init__.py | 3 ++- mail_debrand/models/mail_mail.py | 24 +++++++++++++++++++ ...inANDmail_mail.py => mail_render_mixin.py} | 19 --------------- 3 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 mail_debrand/models/mail_mail.py rename mail_debrand/models/{mail_render_mixinANDmail_mail.py => mail_render_mixin.py} (86%) diff --git a/mail_debrand/models/__init__.py b/mail_debrand/models/__init__.py index 0e99243..1532c75 100644 --- a/mail_debrand/models/__init__.py +++ b/mail_debrand/models/__init__.py @@ -1 +1,2 @@ -from . import mail_render_mixinANDmail_mail +from . import mail_render_mixin +from . import mail_mail diff --git a/mail_debrand/models/mail_mail.py b/mail_debrand/models/mail_mail.py new file mode 100644 index 0000000..c36a4ed --- /dev/null +++ b/mail_debrand/models/mail_mail.py @@ -0,0 +1,24 @@ +# 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). +from odoo import api, models + + +class MailMail(models.AbstractModel): + _inherit = "mail.mail" + + # in messages from objects is adding using Odoo that we are going to remove + + @api.model_create_multi + def create(self, values_list): + for index, _value in enumerate(values_list): + values_list[index]["body_html"] = self.env[ + "mail.render.mixin" + ].remove_href_odoo( + values_list[index].get("body_html", ""), + remove_parent=0, + remove_before=1, + ) + + return super().create(values_list) diff --git a/mail_debrand/models/mail_render_mixinANDmail_mail.py b/mail_debrand/models/mail_render_mixin.py similarity index 86% rename from mail_debrand/models/mail_render_mixinANDmail_mail.py rename to mail_debrand/models/mail_render_mixin.py index 01581c5..00524a5 100644 --- a/mail_debrand/models/mail_render_mixinANDmail_mail.py +++ b/mail_debrand/models/mail_render_mixin.py @@ -88,22 +88,3 @@ class MailRenderMixin(models.AbstractModel): orginal_rendered[key] = self.remove_href_odoo(orginal_rendered[key]) return orginal_rendered - - -class MailMail(models.AbstractModel): - _inherit = "mail.mail" - - # in messages from objects is adding using Odoo that we are going to remove - - @api.model_create_multi - def create(self, values_list): - for index, _value in enumerate(values_list): - values_list[index]["body_html"] = self.env[ - "mail.render.mixin" - ].remove_href_odoo( - values_list[index].get("body_html", ""), - remove_parent=0, - remove_before=1, - ) - - return super().create(values_list)