darshan-serpent
8 years ago
committed by
Pedro M. Baeza
8 changed files with 124 additions and 148 deletions
-
14mail_debrand/README.rst
-
3mail_debrand/__init__.py
-
14mail_debrand/__openerp__.py
-
109mail_debrand/data/mail_data.xml
-
5mail_debrand/models/__init__.py
-
51mail_debrand/models/mail.py
-
5mail_debrand/tests/__init__.py
-
71mail_debrand/tests/test_mail.py
@ -1,5 +1,2 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis |
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
from . import models |
|
@ -1,16 +1,20 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis |
|
||||
|
# Copyright 2016 Tecnativa - Jairo Llopis |
||||
|
# Copyright 2017 SerpentCS - Darshan Patel |
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
{ |
{ |
||||
"name": "Mail Debrand", |
"name": "Mail Debrand", |
||||
"summary": "Remove Odoo branding from email footers", |
|
||||
"version": "8.0.1.0.0", |
|
||||
|
"summary": "Remove Odoo branding in sent emails", |
||||
|
"version": "9.0.1.0.0", |
||||
"category": "Social Network", |
"category": "Social Network", |
||||
"website": "http://www.antiun.com", |
|
||||
"author": "Antiun Ingeniería S.L., Odoo Community Association (OCA)", |
|
||||
|
"website": "https://www.tecnativa.com", |
||||
|
"author": "Tecnativa, " |
||||
|
"Eficent, " |
||||
|
"Odoo Community Association (OCA)", |
||||
"license": "AGPL-3", |
"license": "AGPL-3", |
||||
"application": False, |
"application": False, |
||||
"installable": True, |
"installable": True, |
||||
|
"data": ["data/mail_data.xml"], |
||||
"depends": [ |
"depends": [ |
||||
"mail", |
"mail", |
||||
], |
], |
||||
|
@ -0,0 +1,109 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Copyright 2017 Eficent Business and IT Consulting Services S.L. |
||||
|
Serpent Consulting Services Pvt. Ltd. |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0) --> |
||||
|
<odoo> |
||||
|
<!--Default Notification Email template --> |
||||
|
<record id="mail.mail_template_data_notification_email_default" model="mail.template"> |
||||
|
<field name="body_html"><![CDATA[ |
||||
|
<div itemscope itemtype="http://schema.org/EmailMessage"> |
||||
|
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction"> |
||||
|
% if ctx.get('button_access'): |
||||
|
<link itemprop="target" href="${ctx['button_access']['url']}"/> |
||||
|
<link itemprop="url" href="${ctx['button_access']['url']}"/> |
||||
|
% endif |
||||
|
<meta itemprop="name" content="View ${ctx['model_name']}"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div summary="o_mail_notification" style="padding:0px; width:600px; margin:0 auto; background: #FFFFFF repeat top /100%; color:#777777"> |
||||
|
<table cellspacing="0" cellpadding="0" style="width:600px; border-collapse:collapse; background:inherit; color:inherit"> |
||||
|
<tbody><tr> |
||||
|
<td valign="center" width="270" style="padding:5px 10px 5px 5px;font-size: 30px"> |
||||
|
% if ctx.get('button_access'): |
||||
|
<a href="${ctx['button_access']['url']}" style="-webkit-user-select: none; padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#a24689; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #a24689; border: 1px solid #a24689; border-radius:3px" class="o_default_snippet_text">${ctx['button_access']['title']}</a> |
||||
|
% endif |
||||
|
|
||||
|
% if ctx.get('button_follow'): |
||||
|
<a href="${ctx['button_follow']['url']}" style="-webkit-user-select: none; padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#a24689; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #a24689; border: 1px solid #a24689; border-radius:3px" class="o_default_snippet_text">${ctx['button_follow']['title']}</a> |
||||
|
|
||||
|
% elif ctx.get('button_unfollow'): |
||||
|
<a href="${ctx['button_unfollow']['url']}" style="-webkit-user-select: none; padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#a24689; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #a24689; border: 1px solid #a24689; border-radius:3px" class="o_default_snippet_text">${ctx['button_unfollow']['title']}</a> |
||||
|
% endif |
||||
|
|
||||
|
% if not ctx.get('button_access') and not ctx.get('button_follow') and not ctx.get('button_unfollow') and ctx.get('model_name'): |
||||
|
<p style="padding: 5px 10px; font-size: 12px;"> |
||||
|
About <strong>${ctx['model_name']} |
||||
|
% if ctx.get('record_name'): |
||||
|
: ${ctx['record_name']} |
||||
|
% endif |
||||
|
</strong> |
||||
|
</p> |
||||
|
% endif |
||||
|
</td> |
||||
|
<td valign="center" align="right" width="270" style="padding:5px 15px 5px 10px; font-size: 12px;"> |
||||
|
<p> |
||||
|
% if ctx.get('actions'): |
||||
|
% for action in ctx['actions']: |
||||
|
<a href="${action['url']}" style="text-decoration:none; color: #a24689;"><strong>${action['title']}</strong></a> |
||||
|
%if cmp(len(ctx['actions']), 1) == 1 and cmp(len(ctx['actions']), loop.index) == 1: |
||||
|
| |
||||
|
% endif |
||||
|
% endfor |
||||
|
% else: |
||||
|
<strong>Sent by</strong> |
||||
|
% if ctx.get('website_url'): |
||||
|
<a href="${ctx['website_url']}" style="text-decoration:none; color: #a24689;"> |
||||
|
% endif |
||||
|
<strong>${ctx.get('company_name')}</strong> |
||||
|
% if ctx.get('website_url'): |
||||
|
</a> |
||||
|
% endif |
||||
|
% endif |
||||
|
</p> |
||||
|
</td> |
||||
|
</tr> |
||||
|
</tbody></table> |
||||
|
</div> |
||||
|
<div style="padding:0px; width:600px; margin:0 auto; background: #FFFFFF repeat top /100%; color:#777777"> |
||||
|
<table cellspacing="0" cellpadding="0" style="vertical-align:top; padding:0px; border-collapse:collapse; background:inherit; color:inherit"> |
||||
|
<tbody><tr> |
||||
|
<td valign="top" style="width:600px; padding:5px 10px 5px 5px;"> |
||||
|
<div> |
||||
|
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0;margin:15px auto;padding:0"> |
||||
|
</div> |
||||
|
</td> |
||||
|
</tr></tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<div style="padding:0px; width:600px; margin:0 auto; background: #FFFFFF repeat top /100%;color:#777777"> |
||||
|
<table cellspacing="0" cellpadding="0" border="0" style="margin: 0 auto; width:600px; border-collapse:collapse; background:inherit; color:inherit"> |
||||
|
<tbody><tr> |
||||
|
<td style="padding:5px 10px 5px 5px;font-size: 14px;"> |
||||
|
${object.body | safe} |
||||
|
% if ctx.get('tracking'): |
||||
|
<ul> |
||||
|
% for tracking in ctx['tracking'] |
||||
|
<li>${tracking[0]} : ${tracking[1]} -> ${tracking[2]}</li> |
||||
|
% endfor |
||||
|
</ul> |
||||
|
% endif |
||||
|
</td> |
||||
|
</tr></tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
% if ctx.get('signature'): |
||||
|
<div style="padding:0px; width:600px;margin:0 auto; background: #FFFFFF repeat top /100%;color:#777777"> |
||||
|
<table cellspacing="0" cellpadding="0" border="0" style="margin: 0 auto; width:600px; border-collapse:collapse; background:inherit; color:inherit"> |
||||
|
<tbody><tr> |
||||
|
<td style="padding:5px 10px 5px 5px;font-size: 14px; text-align: left;"> |
||||
|
${ctx['signature'] | safe} |
||||
|
</td> |
||||
|
</tr></tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
% endif |
||||
|
]]> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -1,5 +0,0 @@ |
|||||
# -*- 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 |
|
@ -1,51 +0,0 @@ |
|||||
# -*- 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 |
|
@ -1,5 +0,0 @@ |
|||||
# -*- 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 |
|
@ -1,71 +0,0 @@ |
|||||
# -*- 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