diff --git a/mail_debrand/README.rst b/mail_debrand/README.rst new file mode 100644 index 0000000000..8984ace7d8 --- /dev/null +++ b/mail_debrand/README.rst @@ -0,0 +1,131 @@ +============ +Mail Debrand +============ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8894aff06c4c2d15c42f627ef109899961a28b70155b30b6fa26dfa1508c4594 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/18.0/mail_debrand + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-18-0/social-18-0-mail_debrand + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module modifies the functionality of emails to remove the Odoo +branding, specifically the 'Powered by Odoo' + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +- Install it. +- Send an email. +- Nobody will know it comes from Odoo. + +Known issues / Roadmap +====================== + +Known issues: + +- Not all branding is removed from auth_signup's invitation email + because it is a longer, more complex snippet of HTML. Only the line + containing the link to Odoo.com is removed. + +Changelog +========= + +15.0.1.2.3 (2022-07-19) +----------------------- + +- [FIX] https://github.com/OCA/social/issues/915 +- [FIX] https://github.com/OCA/social/issues/936 + +12.0.1.0.0 (2018-11-06) +----------------------- + +- [NEW] Initial V12 version. Complete rewrite from v11. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa +* ForgeFlow +* Onestein +* Sodexis +* Nexterp Romania + +Contributors +------------ + +- Lois Rilo +- Graeme Gellatly +- `Tecnativa `__: + + - Pedro M. Baeza + - João Marques + +- Stefan Rijnhart stefan@opener.amsterdam + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px + :target: https://github.com/pedrobaeza + :alt: pedrobaeza +.. |maintainer-joao-p-marques| image:: https://github.com/joao-p-marques.png?size=40px + :target: https://github.com/joao-p-marques + :alt: joao-p-marques + +Current `maintainers `__: + +|maintainer-pedrobaeza| |maintainer-joao-p-marques| + +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_debrand/__init__.py b/mail_debrand/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/mail_debrand/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/mail_debrand/__manifest__.py b/mail_debrand/__manifest__.py new file mode 100644 index 0000000000..3c4a593c4e --- /dev/null +++ b/mail_debrand/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2016 Tecnativa - Jairo Llopis +# Copyright 2017 Tecnativa - Pedro M. Baeza +# Copyright 2019 ForgeFlow S.L. - Lois Rilo +# 2020 NextERP Romania +# Copyright 2021 Tecnativa - João Marques +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Mail Debrand", + "summary": """Remove Odoo branding in sent emails + Removes anchor 20characters + """, + "version": "18.0.1.0.0", + "category": "Social Network", + "website": "https://github.com/OCA/social", + "author": """Tecnativa, ForgeFlow, Onestein, Sodexis, Nexterp Romania, + Odoo Community Association (OCA)""", + "license": "AGPL-3", + "installable": True, + "depends": ["mail"], + "development_status": "Production/Stable", + "maintainers": ["pedrobaeza", "joao-p-marques"], +} diff --git a/mail_debrand/i18n/es.po b/mail_debrand/i18n/es.po new file mode 100644 index 0000000000..5433af2ef5 --- /dev/null +++ b/mail_debrand/i18n/es.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-09-03 13:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "Conectar" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "Mezcla de renderizado de correo" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "Correos salientes" + +#~ msgid "Display Name" +#~ msgstr "Nombre mostrado" + +#~ msgid "Last Modified on" +#~ msgstr "Última modificación en" diff --git a/mail_debrand/i18n/fr.po b/mail_debrand/i18n/fr.po new file mode 100644 index 0000000000..996a852ecc --- /dev/null +++ b/mail_debrand/i18n/fr.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-23 16:34+0000\n" +"Last-Translator: Vincent Hatakeyama \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "Connexion" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "Mixin de rendu de courriel" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "Courriels sortants" + +#~ msgid "Email Templates" +#~ msgstr "Modèles d'emails" + +#~ msgid "Email Thread" +#~ msgstr "Discussion par email" + +#~ msgid "Odoo" +#~ msgstr "Odoo" + +#~ msgid "Powered by" +#~ msgstr "Propulsé par" + +#~ msgid "using" +#~ msgstr "utilisant" diff --git a/mail_debrand/i18n/fr_FR.po b/mail_debrand/i18n/fr_FR.po new file mode 100644 index 0000000000..bc28f4f709 --- /dev/null +++ b/mail_debrand/i18n/fr_FR.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-04-11 18:46+0000\n" +"Last-Translator: Yves Le Doeuff \n" +"Language-Team: none\n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "Rendu du courrier" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "E-mails sortants" + +#~ msgid "Display Name" +#~ msgstr "Nom affiché" + +#~ msgid "Last Modified on" +#~ msgstr "Dernière modification" diff --git a/mail_debrand/i18n/it.po b/mail_debrand/i18n/it.po new file mode 100644 index 0000000000..48bcb396e3 --- /dev/null +++ b/mail_debrand/i18n/it.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-07-08 08:59+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "Connetti" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "Mixin resa posta" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "Posta in uscita" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/mail_debrand/i18n/mail_debrand.pot b/mail_debrand/i18n/mail_debrand.pot new file mode 100644 index 0000000000..ef4fcee7c5 --- /dev/null +++ b/mail_debrand/i18n/mail_debrand.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \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 +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "" diff --git a/mail_debrand/i18n/nl.po b/mail_debrand/i18n/nl.po new file mode 100644 index 0000000000..92f5c77c2b --- /dev/null +++ b/mail_debrand/i18n/nl.po @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-05-17 21:47+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "" + +#, fuzzy +#~ msgid "Email Templates" +#~ msgstr "Email Templates" + +#, fuzzy +#~ msgid "Email Thread" +#~ msgstr "Email Thread" + +#, fuzzy +#~ msgid "Odoo" +#~ msgstr "Odoo" + +#~ msgid "Powered by" +#~ msgstr "Aangeboden door" diff --git a/mail_debrand/i18n/pt.po b/mail_debrand/i18n/pt.po new file mode 100644 index 0000000000..f10b3de13c --- /dev/null +++ b/mail_debrand/i18n/pt.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-03-02 17:13+0000\n" +"Last-Translator: Pedro Castro Silva \n" +"Language-Team: none\n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "" + +#~ msgid "Email Templates" +#~ msgstr "Modelos de Email" + +#~ msgid "Email Thread" +#~ msgstr "Thread do email" diff --git a/mail_debrand/i18n/sl.po b/mail_debrand/i18n/sl.po new file mode 100644 index 0000000000..bb210f71d4 --- /dev/null +++ b/mail_debrand/i18n/sl.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-03-19 10:13+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 3.10\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "" + +#~ msgid "Email Templates" +#~ msgstr "Predloge e-pošte" + +#~ msgid "Email Thread" +#~ msgstr "E-poštna nit" + +#~ msgid "Odoo" +#~ msgstr "Odoo" + +#~ msgid "Powered by" +#~ msgstr "Powered by" + +#~ msgid "using" +#~ msgstr "z uporabo" diff --git a/mail_debrand/i18n/sr_Latn.po b/mail_debrand/i18n/sr_Latn.po new file mode 100644 index 0000000000..c0c02bb752 --- /dev/null +++ b/mail_debrand/i18n/sr_Latn.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: sr_Latn\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "" diff --git a/mail_debrand/i18n/sv.po b/mail_debrand/i18n/sv.po new file mode 100644 index 0000000000..7dfb1698f3 --- /dev/null +++ b/mail_debrand/i18n/sv.po @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-11-17 10:36+0000\n" +"Last-Translator: Simon S \n" +"Language-Team: none\n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: mail_debrand +#. odoo-python +#: code:addons/mail_debrand/tests/test_mail_debrand_digest.py:0 +#, python-format +msgid "Connect" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_render_mixin +msgid "Mail Render Mixin" +msgstr "" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_mail +msgid "Outgoing Mails" +msgstr "Utgående e-postmeddelanden" + +#~ msgid "Display Name" +#~ msgstr "Visningsnamn" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Senast ändrad den" diff --git a/mail_debrand/models/__init__.py b/mail_debrand/models/__init__.py new file mode 100644 index 0000000000..1532c7546a --- /dev/null +++ b/mail_debrand/models/__init__.py @@ -0,0 +1,2 @@ +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 0000000000..099f32092d --- /dev/null +++ b/mail_debrand/models/mail_mail.py @@ -0,0 +1,15 @@ +# 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 models + + +class MailMail(models.AbstractModel): + _inherit = "mail.mail" + + def _prepare_outgoing_body(self): + body_html = super()._prepare_outgoing_body() + return self.env["mail.render.mixin"].remove_href_odoo( + body_html or "", to_keep=self.body + ) diff --git a/mail_debrand/models/mail_render_mixin.py b/mail_debrand/models/mail_render_mixin.py new file mode 100644 index 0000000000..5497828862 --- /dev/null +++ b/mail_debrand/models/mail_render_mixin.py @@ -0,0 +1,96 @@ +# 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 + + +class MailRenderMixin(models.AbstractModel): + _inherit = "mail.render.mixin" + + def remove_href_odoo(self, value, to_keep=None): + if len(value) < 20: + return value + # value can be bytes or markup; ensure we get a proper string and preserve type + back_to_bytes = False + back_to_markup = False + if isinstance(value, bytes): + back_to_bytes = True + value = value.decode() + if isinstance(value, Markup): + back_to_markup = True + 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() + # Remove "Powered by", "using" etc. + previous = elem.getprevious() + if previous is not None: + previous.tail = etree.CDATA(" ") + elif parent.text: + parent.text = etree.CDATA(" ") + parent.remove(elem) + value = etree.tostring( + tree, pretty_print=True, method="html", encoding="unicode" + ) + if to_keep: + value = value.replace("", to_keep) + if back_to_bytes: + value = value.encode() + elif back_to_markup: + value = Markup(value) + return value + + @api.model + def _render_template( + self, + template_src, + model, + res_ids, + engine="inline_template", + add_context=None, + options=None, + ): + """replace anything that is with odoo in templates + if is a \> +- Graeme Gellatly \<\> +- [Tecnativa](https://www.tecnativa.com): + - Pedro M. Baeza + - João Marques +- Stefan Rijnhart diff --git a/mail_debrand/readme/DESCRIPTION.md b/mail_debrand/readme/DESCRIPTION.md new file mode 100644 index 0000000000..e0c8789a27 --- /dev/null +++ b/mail_debrand/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module modifies the functionality of emails to remove the Odoo +branding, specifically the 'Powered by Odoo' diff --git a/mail_debrand/readme/HISTORY.md b/mail_debrand/readme/HISTORY.md new file mode 100644 index 0000000000..888b4a9021 --- /dev/null +++ b/mail_debrand/readme/HISTORY.md @@ -0,0 +1,8 @@ +## 15.0.1.2.3 (2022-07-19) + +- \[FIX\] +- \[FIX\] + +## 12.0.1.0.0 (2018-11-06) + +- \[NEW\] Initial V12 version. Complete rewrite from v11. diff --git a/mail_debrand/readme/ROADMAP.md b/mail_debrand/readme/ROADMAP.md new file mode 100644 index 0000000000..08bc7b2f25 --- /dev/null +++ b/mail_debrand/readme/ROADMAP.md @@ -0,0 +1,5 @@ +Known issues: + +- Not all branding is removed from auth_signup's invitation email + because it is a longer, more complex snippet of HTML. Only the line + containing the link to Odoo.com is removed. diff --git a/mail_debrand/readme/USAGE.md b/mail_debrand/readme/USAGE.md new file mode 100644 index 0000000000..44e4351e57 --- /dev/null +++ b/mail_debrand/readme/USAGE.md @@ -0,0 +1,5 @@ +To use this module, you need to: + +- Install it. +- Send an email. +- Nobody will know it comes from Odoo. diff --git a/mail_debrand/static/description/icon.png b/mail_debrand/static/description/icon.png new file mode 100644 index 0000000000..06a30af919 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 0000000000..6609694dfb --- /dev/null +++ b/mail_debrand/static/description/icon.svg @@ -0,0 +1,248 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mail_debrand/static/description/index.html b/mail_debrand/static/description/index.html new file mode 100644 index 0000000000..cc8c6d532f --- /dev/null +++ b/mail_debrand/static/description/index.html @@ -0,0 +1,475 @@ + + + + + +Mail Debrand + + + +
+

Mail Debrand

+ + +

Production/Stable License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

+

This module modifies the functionality of emails to remove the Odoo +branding, specifically the ‘Powered by Odoo’

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  • Install it.
  • +
  • Send an email.
  • +
  • Nobody will know it comes from Odoo.
  • +
+
+
+

Known issues / Roadmap

+

Known issues:

+
    +
  • Not all branding is removed from auth_signup’s invitation email +because it is a longer, more complex snippet of HTML. Only the line +containing the link to Odoo.com is removed.
  • +
+
+
+

Changelog

+ +
+

12.0.1.0.0 (2018-11-06)

+
    +
  • [NEW] Initial V12 version. Complete rewrite from v11.
  • +
+
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
  • ForgeFlow
  • +
  • Onestein
  • +
  • Sodexis
  • +
  • Nexterp Romania
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainers:

+

pedrobaeza joao-p-marques

+

This module is part of the OCA/social project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mail_debrand/tests/__init__.py b/mail_debrand/tests/__init__.py new file mode 100644 index 0000000000..8682c900f5 --- /dev/null +++ b/mail_debrand/tests/__init__.py @@ -0,0 +1,3 @@ +from . import test_mail_debrand +from . import test_mail_debrand_digest +from . import test_mail_debrand_signup diff --git a/mail_debrand/tests/test_mail_debrand.py b/mail_debrand/tests/test_mail_debrand.py new file mode 100644 index 0000000000..e5a11117ba --- /dev/null +++ b/mail_debrand/tests/test_mail_debrand.py @@ -0,0 +1,116 @@ +# Copyright 2017 Tecnativa - Pedro M. Baeza +# Copyright 2020 Onestein - Andrea Stirpe +# Copyright 2021-22 Sodexis +# Copyright 2021 Tecnativa - João Marques +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestMailDebrand(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.mail = cls.env["mail.mail"].create( + { + "email_from": "customer@example.com", + "subject": "Hello", + "email_to": "contact@example.com", + "reply_to": "contact@example.com", + } + ) + lang_nl = cls.env.ref("base.lang_nl") + if not lang_nl.active: + lang_nl.toggle_active() + + def test_debrand_binary_value(self): + """ + Regression test: ensure binary input is gracefully handled + """ + try: + self.env["mail.template"].remove_href_odoo( + b"Binary value with more than 20 characters" + ) + except TypeError: + self.fail("Debranding binary string raised TypeError") + + def _test_debrand_by_lang(self, template_ref, lang, term): + body = self.env["ir.qweb"]._render( + template_ref, + { + "message": self.mail, + "company": self.env.company, + }, + lang=lang.code, + minimal_qcontext=True, + ) + self.assertIn(term, body) + body_cleaned = self.env["mail.render.mixin"].remove_href_odoo(body) + self.assertNotIn(term, body_cleaned) + + def test_default_debrand(self): + self._test_debrand_by_lang( + "mail.mail_notification_layout", + self.env.ref("base.lang_en"), + "Powered by", + ) + + def test_default_debrand_translated(self): + self._test_debrand_by_lang( + "mail.mail_notification_layout", + self.env.ref("base.lang_nl"), + "Aangeboden door", + ) + + def test_light_debrand(self): + self._test_debrand_by_lang( + "mail.mail_notification_light", + self.env.ref("base.lang_en"), + "Powered by", + ) + + def test_light_debrand_translated(self): + self._test_debrand_by_lang( + "mail.mail_notification_light", + self.env.ref("base.lang_nl"), + "Aangeboden door", + ) + + def test_body_intact(self): + """The message body should never be changed""" + MailMessage = self.env["mail.mail"] + original_body = ( + "

And if I send odoo.example.com

And odoo.com" + '

And https://odoo.com

And ' + 'https://odoo.example.com

' + ) + email_values = { + "email_from": "customer@example.com", + "subject": "Hello", + "email_to": "contact@example.com", + "reply_to": "contact@example.com", + "body": original_body, + "body_html": ( + "\n
\n\n\n

And if I send odoo.example.com

" + 'And odoo.com

And ' + 'https://odoo.com

And ' + "https://odoo.example.com

\n\n" + '
-- ' + '
\nAdministrator
\n' + '

\n Sent\n ' + '\n by\n \n ' + "YourCompany\n \n \n \n " + 'using\n Odoo' + ".\n

\n
\n " + ), + } + # No exception expected + message = MailMessage.create(email_values) + self.assertTrue(original_body in message._prepare_outgoing_body()) diff --git a/mail_debrand/tests/test_mail_debrand_digest.py b/mail_debrand/tests/test_mail_debrand_digest.py new file mode 100644 index 0000000000..14f8b9e5ad --- /dev/null +++ b/mail_debrand/tests/test_mail_debrand_digest.py @@ -0,0 +1,72 @@ +# Copyright 2017 Tecnativa - Pedro M. Baeza +# Copyright 2020 Onestein - Andrea Stirpe +# Copyright 2021-22 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from datetime import datetime + +from werkzeug.urls import url_join + +from odoo.tests import common, tagged + + +@tagged("-at_install", "post_install") +class TestMailDebrandDigest(common.TransactionCase): + def setUp(self): + super().setUp() + if "digest.digest" in self.env: + self.mail_digest_id = self.env["digest.digest"].create( + { + "name": "Test Digest", + "user_ids": False, + "company_id": self.env.company.id, + "kpi_res_users_connected": True, + "kpi_mail_message_total": True, + } + ) + else: + self.mail_digest_id = False + + def test_mail_digest(self): + if not self.mail_digest_id: + self.assertEqual(True, True) + return + + web_base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url") + rendered_body = self.env["mail.render.mixin"]._render_template( + "digest.digest_mail_main", + "digest.digest", + self.mail_digest_id.ids, + engine="qweb_view", + add_context={ + "title": self.mail_digest_id.name, + "top_button_label": self.env._("Connect"), + "top_button_url": url_join(web_base_url, "/web/login"), + "company": self.env.user.company_id, + "user": self.env.user, + "tips_count": 1, + "formatted_date": datetime.today().strftime("%B %d, %Y"), + "display_mobile_banner": True, + "kpi_data": self.mail_digest_id._compute_kpis( + self.env.user.company_id, self.env.user + ), + "tips": self.mail_digest_id._compute_tips( + self.env.user.company_id, self.env.user, tips_count=1, consumed=True + ), + "preferences": self.mail_digest_id._compute_preferences( + self.env.user.company_id, self.env.user + ), + }, + options={ + "post_process": True, + }, + )[self.mail_digest_id.id] + + # ensure the template rendered correctly. if rendering failed, + # we sometimes end up with a string only containing the template + # name, or a null-ish value + self.assertNotEqual(rendered_body, "digest.digest_mail_main") + self.assertNotEqual(rendered_body, None) + self.assertNotEqual(rendered_body, False) + self.assertNotEqual(rendered_body, "") + self.assertNotIn("Powered by", rendered_body) diff --git a/mail_debrand/tests/test_mail_debrand_signup.py b/mail_debrand/tests/test_mail_debrand_signup.py new file mode 100644 index 0000000000..107f06478a --- /dev/null +++ b/mail_debrand/tests/test_mail_debrand_signup.py @@ -0,0 +1,28 @@ +from odoo.tests import TransactionCase, tagged + + +@tagged("-at_install", "post_install") +class TestMailDebrandSignup(TransactionCase): + def _has_module(self): + module = self.env["ir.module.module"].search([("name", "=", "auth_signup")]) + self.assertTrue(module) + return module.state == "installed" + + def test_debrand_auth_signup_set_password_email(self): + if not self._has_module(): + return + template = self.env.ref( + "auth_signup.set_password_email", + ) + self.assertIn("www.odoo.com", template.body_html) + self.assertIn("Accept invitation", template.body_html) + self.assertIn("to discover the tool", template.body_html) + + mail_id = template.send_mail(self.env.user.id) + body = self.env["mail.mail"].browse(mail_id).body_html + + # The essential button is preserved + self.assertIn("Accept invitation", body) + # But at least part of the branding was removed + self.assertNotIn("www.odoo.com", body) + self.assertNotIn("to discover the tool", body)