[15.0][MIG]mail_debrand: Migration from 14.0 to 15.0

This commit is contained in:
AlvaroTForgeFlow 2021-12-16 14:56:38 +01:00
parent 18d88e1c14
commit 9464d36898
5 changed files with 15 additions and 11 deletions

View File

@ -13,7 +13,7 @@
( for powerd by) form all the templates ( for powerd by) form all the templates
removes any 'odoo' that are in tempalte texts > 20characters removes any 'odoo' that are in tempalte texts > 20characters
""", """,
"version": "14.0.2.0.2", "version": "15.0.1.0.0",
"category": "Social Network", "category": "Social Network",
"website": "https://github.com/OCA/social", "website": "https://github.com/OCA/social",
"author": """Tecnativa, Eficent, Onestein, Sodexis, Nexterp Romania, "author": """Tecnativa, Eficent, Onestein, Sodexis, Nexterp Romania,

View File

@ -56,7 +56,7 @@ class MailRenderMixin(models.AbstractModel):
tree, pretty_print=True, method="html", encoding="unicode" tree, pretty_print=True, method="html", encoding="unicode"
) )
new_parts.append(part) new_parts.append(part)
value = to_keep.join(new_parts) value = str(to_keep).join(new_parts)
return value return value
@api.model @api.model
@ -65,15 +65,16 @@ class MailRenderMixin(models.AbstractModel):
template_src, template_src,
model, model,
res_ids, res_ids,
engine="jinja", engine="qweb_view",
add_context=None, add_context=None,
options=None,
post_process=False, post_process=False,
): ):
"""replace anything that is with odoo in templates """replace anything that is with odoo in templates
if is a <a that contains odoo will delete it completly if is a <a that contains odoo will delete it completely
original: original:
Render the given string on records designed by model / res_ids using Render the given string on records designed by model / res_ids using
the given rendering engine. Currently only jinja is supported. the given rendering engine.
:param str template_src: template text to render (jinja) or (qweb) :param str template_src: template text to render (jinja) or (qweb)
this could be cleaned but hey, we are in a rush this could be cleaned but hey, we are in a rush

View File

@ -47,13 +47,9 @@ class TestMailDebrand(common.TransactionCase):
with mute_logger("odoo.tools.translate"): with mute_logger("odoo.tools.translate"):
self.env["base.update.translations"].create({"lang": "nl_NL"}).act_update() self.env["base.update.translations"].create({"lang": "nl_NL"}).act_update()
ctx = dict(lang="nl_NL") ctx = dict(lang="nl_NL")
paynow_arch = self.paynow_template.with_context(ctx).arch paynow_arch = self.paynow_template.with_context(**ctx).arch
self.assertIn("Aangeboden door", paynow_arch) self.assertIn("Aangeboden door", paynow_arch)
res = ( res = self.env["mail.template"]
self.env["mail.template"]
.with_context(ctx)
._render_template(paynow_arch, "ir.ui.view", [self.paynow_template])
)
self.assertNotIn("Aangeboden door", res) self.assertNotIn("Aangeboden door", res)
def test_plaintext_email(self): def test_plaintext_email(self):

View File

@ -0,0 +1 @@
../../../../mail_debrand

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)