diff --git a/mail_debrand/README.rst b/mail_debrand/README.rst new file mode 100644 index 00000000..d9f21516 --- /dev/null +++ b/mail_debrand/README.rst @@ -0,0 +1,73 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============ +Mail Debrand +============ + +This module modifies the functionality of emails to remove the Odoo branding. + +It also allows some context options to remove user and company signatures too. + +Usage +===== + +To use this module, you need to: + +* Install it. +* Send an email. +* Nobody will know it comes from Odoo. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/205/10.0 + + +Known issues / Roadmap +====================== + +* This module relies on the translation of the strings here in this module that + must match the mail notification template translation on Odoo core, + specifically the words "using" and "Odoo". + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Rafael Blasco +* Jairo Llopis +* Jordi Ballester Alomar +* Darshan Patel +* Pedro M. Baeza + +Images +------ + +* https://openclipart.org/detail/29117/unread-mail-icon +* https://openclipart.org/detail/147961/panneau-interdit-forbidden-road-sign-basic + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/mail_debrand/__init__.py b/mail_debrand/__init__.py new file mode 100644 index 00000000..a77a6fcb --- /dev/null +++ b/mail_debrand/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/mail_debrand/__openerp__.py b/mail_debrand/__openerp__.py new file mode 100644 index 00000000..9445ac5d --- /dev/null +++ b/mail_debrand/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Tecnativa - Jairo Llopis +# Copyright 2017 SerpentCS - Darshan Patel +# Copyright 2017 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Mail Debrand", + "summary": "Remove Odoo branding in sent emails", + "version": "10.0.1.0.0", + "category": "Social Network", + "website": "https://www.tecnativa.com", + "author": "Tecnativa, " + "Eficent, " + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": [ + "mail", + ], +} diff --git a/mail_debrand/i18n/es.po b/mail_debrand/i18n/es.po new file mode 100644 index 00000000..d0eb1d65 --- /dev/null +++ b/mail_debrand/i18n/es.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-15 14:50+0000\n" +"PO-Revision-Date: 2017-05-15 14:50+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_template +msgid "Email Templates" +msgstr "Plantillas de correo electrónico" + +#. module: mail_debrand +#: code:addons/mail_debrand/models/mail_template.py:26 +#, python-format +msgid "Odoo" +msgstr "Odoo" + +#. module: mail_debrand +#: code:addons/mail_debrand/models/mail_template.py:25 +#, python-format +msgid "using" +msgstr "usando" + diff --git a/mail_debrand/models/__init__.py b/mail_debrand/models/__init__.py new file mode 100644 index 00000000..c290298c --- /dev/null +++ b/mail_debrand/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import mail_template diff --git a/mail_debrand/models/mail_template.py b/mail_debrand/models/mail_template.py new file mode 100644 index 00000000..d4b984db --- /dev/null +++ b/mail_debrand/models/mail_template.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import re +from odoo import _, api, models + + +class MailTemplate(models.Model): + _inherit = 'mail.template' + + @api.multi + def generate_email(self, res_ids, fields=None): + mail_template = self.env.ref( + 'mail.mail_template_data_notification_email_default' + ) + if self == mail_template: + obj = self.with_context(mail_debrand=True) + else: + obj = self + return super(MailTemplate, obj).generate_email(res_ids, fields=fields) + + @api.model + def _debrand_body(self, body): + using_word = _('using') + odoo_word = _('Odoo') + return re.sub( + using_word + "(.*)[\r\n]*(.*)>" + odoo_word + r"", "", body, + ) + + @api.model + def render_template(self, template_txt, model, res_ids, + post_process=False): + res = super(MailTemplate, self).render_template( + template_txt, model, res_ids, post_process=post_process, + ) + if post_process and self.env.context.get('mail_debrand'): + if isinstance(res, basestring): + res = self._debrand_body(res) + else: + for res_id, body in res.iteritems(): + res[res_id] = self._debrand_body(body) + return res diff --git a/mail_debrand/static/description/icon.png b/mail_debrand/static/description/icon.png new file mode 100644 index 00000000..06a30af9 Binary files /dev/null and b/mail_debrand/static/description/icon.png differ diff --git a/mail_debrand/static/description/icon.svg b/mail_debrand/static/description/icon.svg new file mode 100644 index 00000000..6609694d --- /dev/null +++ b/mail_debrand/static/description/icon.svg @@ -0,0 +1,248 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mail_debrand/tests/__init__.py b/mail_debrand/tests/__init__.py new file mode 100644 index 00000000..62fe23ea --- /dev/null +++ b/mail_debrand/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mail_debrand diff --git a/mail_debrand/tests/test_mail_debrand.py b/mail_debrand/tests/test_mail_debrand.py new file mode 100644 index 00000000..4878adf9 --- /dev/null +++ b/mail_debrand/tests/test_mail_debrand.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestMailDebrand(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestMailDebrand, cls).setUpClass() + cls.template = cls.env.ref( + 'mail.mail_template_data_notification_email_default' + ) + + def test_generate_email_simple(self): + res = self.template.generate_email( + self.env.user.id, fields=['body_html'], + ) + self.assertNotIn('using', res) + + def test_generate_email_multi(self): + res = self.template.generate_email( + self.env.user.ids, fields=['body_html'], + ) + self.assertNotIn('using', res[res.keys()[0]])