diff --git a/mail_debrand/README.rst b/mail_debrand/README.rst new file mode 100644 index 00000000..2a813836 --- /dev/null +++ b/mail_debrand/README.rst @@ -0,0 +1,60 @@ +.. 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/8.0 + +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 + +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..ac009a20 --- /dev/null +++ b/mail_debrand/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# 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..220e0212 --- /dev/null +++ b/mail_debrand/__openerp__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Mail Debrand", + "summary": "Remove Odoo branding from email footers", + "version": "8.0.1.0.0", + "category": "Social Network", + "website": "http://www.antiun.com", + "author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "mail", + ], +} diff --git a/mail_debrand/i18n/es.po b/mail_debrand/i18n/es.po new file mode 100644 index 00000000..ff29caa8 --- /dev/null +++ b/mail_debrand/i18n/es.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mail_debrand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-03-04 15:42+0000\n" +"PO-Revision-Date: 2016-03-04 16:44+0100\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: es\n" +"X-Generator: Poedit 1.8.6\n" + +#. module: mail_debrand +#: model:ir.model,name:mail_debrand.model_mail_notification +msgid "Notifications" +msgstr "Notificaciones" + +#. module: mail_debrand +#: code:addons/mail_debrand/models/mail.py:51 +#, python-format +msgid "Sent by %s" +msgstr "Enviado por %s" diff --git a/mail_debrand/models/__init__.py b/mail_debrand/models/__init__.py new file mode 100644 index 00000000..831774a4 --- /dev/null +++ b/mail_debrand/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import mail diff --git a/mail_debrand/models/mail.py b/mail_debrand/models/mail.py new file mode 100644 index 00000000..d28960ff --- /dev/null +++ b/mail_debrand/models/mail.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import _, api, models, tools + + +class MailNotification(models.Model): + _inherit = "mail.notification" + + @api.model + def _get_signature_footer(self, user_id, res_model=None, res_id=None, + user_signature=True): + """Generate signature footer only with the chosen parts. + + Now, you can set ``skip_signature_user=True`` in the context to remove + the user signature (it's the same as ``user_signature=False``), and + ``skip_signature_company=True`` to remove the company's. + """ + user = self.env["res.users"].browse(user_id) + parts = list() + + if user_signature and not self.env.context.get("skip_signature_user"): + parts.append(self._get_signature_footer_user(user)) + + if not self.env.context.get("skip_signature_company"): + parts.append(self._get_signature_footer_company(user)) + + footer = "" + for part in parts: + footer = tools.append_content_to_html( + footer, part, plaintext=False) + + return footer + + @api.model + def _get_signature_footer_user(self, user): + """User part of the signature.""" + return user.signature if user.signature else "--
%s" % user.name + + def _get_signature_footer_company(self, user): + """Company part of the signature.""" + website = user.company_id.website + if website: + if not website.startswith(('http:', 'https:')): + website = "http://" + website + company = ("%s" % + (website, user.company_id.name)) + else: + company = user.company_id.name + return _('Sent by %s') % company diff --git a/mail_debrand/static/description/icon.png b/mail_debrand/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/mail_debrand/static/description/icon.png differ diff --git a/mail_debrand/tests/__init__.py b/mail_debrand/tests/__init__.py new file mode 100644 index 00000000..992b8166 --- /dev/null +++ b/mail_debrand/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mail diff --git a/mail_debrand/tests/test_mail.py b/mail_debrand/tests/test_mail.py new file mode 100644 index 00000000..b98d19a7 --- /dev/null +++ b/mail_debrand/tests/test_mail.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# © 2016 Antiun Ingeniería S.L. - Jairo Llopis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.tests.common import TransactionCase + + +class SignatureCase(TransactionCase): + def setUp(self): + super(SignatureCase, self).setUp() + self.user = self.env.ref("base.user_demo").with_context(lang="en_US") + self.mail_notification = self.env["mail.notification"].with_context( + lang="en_US") + + def signature(self, **context): + """Get user's signature.""" + return (self.mail_notification.with_context(**context) + ._get_signature_footer(self.user.id)) + + def test_signature_user_custom(self): + """User name does not appear in signature when it is custom.""" + self.user.signature = u"¡Cüstom!" + signature = self.signature() + self.assertNotIn(self.user.name, signature) + + def test_signature_user_empty(self): + """User name appears in signature by default.""" + self.user.signature = False + signature = self.signature() + self.assertIn(self.user.name, signature) + + def test_signature_user_skip(self): + """User signature is skipped.""" + self.user.signature = "Skip me." + signature = self.signature(skip_signature_user=True) + self.assertNotIn(self.user.signature, signature) + + def test_signature_company_website_custom(self): + """Company website link appears in signature.""" + sites = ( + "HTTP://EXAMPLE.COM", + "http://example.com", + "https://example.com", + "HTTPS://example.com," + ) + for site in sites: + for url in (site, site[8:]): + self.user.company_id.website = url + signature = self.signature() + self.assertIn(url, signature) + self.assertIn(self.user.company_id.name, signature) + + def test_signature_company_website_empty(self): + """Company website link does not appear in signature.""" + self.user.company_id.website = False + signature = self.signature() + self.assertNotIn("