Browse Source

[8.0][mail_debrand] Remove branding from mail footers.

Those mail footers odoo sends that say "Sent by YourCompany using Odoo" now say nothing of Odoo.
pull/155/head
Jairo Llopis 9 years ago
committed by darshan-serpent
parent
commit
415a77a391
  1. 60
      mail_debrand/README.rst
  2. 5
      mail_debrand/__init__.py
  3. 17
      mail_debrand/__openerp__.py
  4. 29
      mail_debrand/i18n/es.po
  5. 5
      mail_debrand/models/__init__.py
  6. 51
      mail_debrand/models/mail.py
  7. BIN
      mail_debrand/static/description/icon.png
  8. 5
      mail_debrand/tests/__init__.py
  9. 71
      mail_debrand/tests/test_mail.py

60
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
<https://github.com/OCA/social/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
<https://github.com/OCA/
social/issues/new?body=module:%20
mail_debrand%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
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.

5
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

17
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",
],
}

29
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"

5
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

51
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 "--<br />%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 = ("<a href='%s'>%s</a>" %
(website, user.company_id.name))
else:
company = user.company_id.name
return _('Sent by %s') % company

BIN
mail_debrand/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

5
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

71
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("<a href", signature)
self.assertIn(self.user.company_id.name, signature)
def test_signature_company_skip(self):
"""Company signature is skipped."""
self.user.company_id.website = "http://example.com"
signature = self.signature(skip_signature_company=True)
self.assertNotIn(self.user.company_id.website, signature)
def test_unbranded(self):
"""No Odoo branding found."""
signature = self.signature()
self.assertNotIn("using", signature)
self.assertNotIn("odoo.com", signature)
self.assertNotIn("Odoo", signature)
Loading…
Cancel
Save