Browse Source
Merge pull request #51 from Yajo/mail_debrand
Merge pull request #51 from Yajo/mail_debrand
[8.0][mail_debrand] Remove branding from mail footers.pull/52/head
Rafael Blasco
9 years ago
9 changed files with 243 additions and 0 deletions
-
60mail_debrand/README.rst
-
5mail_debrand/__init__.py
-
17mail_debrand/__openerp__.py
-
29mail_debrand/i18n/es.po
-
5mail_debrand/models/__init__.py
-
51mail_debrand/models/mail.py
-
BINmail_debrand/static/description/icon.png
-
5mail_debrand/tests/__init__.py
-
71mail_debrand/tests/test_mail.py
@ -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. |
@ -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 |
@ -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", |
||||
|
], |
||||
|
} |
@ -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" |
@ -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 |
@ -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 |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -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 |
@ -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) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue