[MIG] mail_debrand: Migration to v13.0

This commit is contained in:
Valentin Vinagre Urteaga 2020-03-20 16:15:04 +01:00 committed by AlvaroTForgeFlow
parent 1143e4226c
commit f15c2638ca
10 changed files with 25 additions and 33 deletions

View File

@ -20,7 +20,7 @@ Mail Debrand
:target: https://runbot.odoo-community.org/runbot/205/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4|
|badge1| |badge2| |badge3| |badge4|
This module modifies the functionality of emails to remove the Odoo branding,
specifically the 'using Odoo' of notifications or the 'Powered by Odoo'
@ -92,7 +92,7 @@ promote its widespread use.
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-pedrobaeza|
|maintainer-pedrobaeza|
This module is part of the `OCA/social <https://github.com/OCA/social/tree/12.0/mail_debrand>`_ project on GitHub.

View File

@ -7,15 +7,13 @@
{
"name": "Mail Debrand",
"summary": "Remove Odoo branding in sent emails",
"version": "12.0.2.0.1",
"version": "13.0.0.0.1",
"category": "Social Network",
"website": "https://github.com/OCA/social/",
"author": "Tecnativa, Eficent, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": [
"mail",
],
"depends": ["mail"],
"development_status": "Stable",
"maintainers": ["pedrobaeza"],
}

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"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 <pedrocs@exo.pt>\n"

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"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 <matjaz@matmoz.si>\n"

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"

View File

@ -1,8 +1,10 @@
# Copyright 2019 O4SB - Graeme Gellatly
# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from lxml import html as htmltree
import re
from lxml import html as htmltree
from odoo import _, api, models
@ -11,18 +13,14 @@ class MailTemplate(models.Model):
@api.model
def _debrand_body(self, html):
using_word = _('using')
odoo_word = _('Odoo')
html = re.sub(
using_word + "(.*)[\r\n]*(.*)>" + odoo_word + r"</a>", "", html,
)
using_word = _("using")
odoo_word = _("Odoo")
html = re.sub(using_word + "(.*)[\r\n]*(.*)>" + odoo_word + r"</a>", "", html)
powered_by = _("Powered by")
if powered_by not in html:
return html
root = htmltree.fromstring(html)
powered_by_elements = root.xpath(
"//*[text()[contains(.,'%s')]]" % powered_by
)
powered_by_elements = root.xpath("//*[text()[contains(.,'%s')]]" % powered_by)
for elem in powered_by_elements:
# make sure it isn't a spurious powered by
if any(

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_debrand"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_debrand"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mail_debrand"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-13-0/social-13-0-mail_debrand"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module modifies the functionality of emails to remove the Odoo branding,
specifically the using Odoo of notifications or the Powered by Odoo</p>
<p><strong>Table of contents</strong></p>
@ -410,7 +410,7 @@ specifically the using Odoo of notifications or the Powered by Odoo<
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_debrand%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_debrand%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -439,7 +439,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/pedrobaeza"><img alt="pedrobaeza" src="https://github.com/pedrobaeza.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/12.0/mail_debrand">OCA/social</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/13.0/mail_debrand">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -7,19 +7,15 @@ from odoo.tests import common
class TestMailDebrand(common.TransactionCase):
def setUp(self):
super().setUp()
self.default_arch = self.env.ref(
'mail.message_notification_email'
).arch
self.paynow_arch = self.env.ref(
'mail.mail_notification_paynow'
).arch
self.default_arch = self.env.ref("mail.message_notification_email").arch
self.paynow_arch = self.env.ref("mail.mail_notification_paynow").arch
def test_default_debrand(self):
self.assertIn('using', self.default_arch)
self.assertIn("using", self.default_arch)
res = self.env["mail.template"]._debrand_body(self.default_arch)
self.assertNotIn('using', res)
self.assertNotIn("using", res)
def test_paynow_debrand(self):
self.assertIn('Powered by', self.paynow_arch)
self.assertIn("Powered by", self.paynow_arch)
res = self.env["mail.template"]._debrand_body(self.paynow_arch)
self.assertNotIn('Powered by', res)
self.assertNotIn("Powered by", res)