mirror of https://github.com/OCA/social.git
[MIG] email_template_qweb: Migration to 14.0
parent
5b2ef9af7c
commit
acb36f7890
|
@ -14,13 +14,13 @@ QWeb for email templates
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
|
||||||
:target: https://github.com/OCA/social/tree/13.0/email_template_qweb
|
:target: https://github.com/OCA/social/tree/14.0/email_template_qweb
|
||||||
:alt: OCA/social
|
:alt: OCA/social
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/social-13-0/social-13-0-email_template_qweb
|
:target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-email_template_qweb
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/205/13.0
|
:target: https://runbot.odoo-community.org/runbot/205/14.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
@ -51,7 +51,7 @@ Bug Tracker
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
|
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.
|
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
|
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:%20email_template_qweb%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/social/issues/new?body=module:%20email_template_qweb%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
@ -74,6 +74,14 @@ Contributors
|
||||||
* Ernesto Tejeda
|
* Ernesto Tejeda
|
||||||
|
|
||||||
* Thomas Fossoul (thomas@niboo.com)
|
* Thomas Fossoul (thomas@niboo.com)
|
||||||
|
* Phuc Tran Thanh <phuc@trobz.com>
|
||||||
|
|
||||||
|
Other credits
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
The development of this module has been financially supported by:
|
||||||
|
|
||||||
|
* Camptocamp
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
@ -88,6 +96,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
This module is part of the `OCA/social <https://github.com/OCA/social/tree/13.0/email_template_qweb>`_ project on GitHub.
|
This module is part of the `OCA/social <https://github.com/OCA/social/tree/14.0/email_template_qweb>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# 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": "QWeb for email templates",
|
"name": "QWeb for email templates",
|
||||||
"version": "13.0.1.0.0",
|
"version": "14.0.1.0.0",
|
||||||
"author": "Therp BV, Odoo Community Association (OCA)",
|
"author": "Therp BV, Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"category": "Marketing",
|
"category": "Marketing",
|
||||||
|
|
|
@ -15,22 +15,24 @@ class MailTemplate(models.Model):
|
||||||
body_view_id = fields.Many2one("ir.ui.view", domain=[("type", "=", "qweb")])
|
body_view_id = fields.Many2one("ir.ui.view", domain=[("type", "=", "qweb")])
|
||||||
body_view_arch = fields.Text(related="body_view_id.arch")
|
body_view_arch = fields.Text(related="body_view_id.arch")
|
||||||
|
|
||||||
def generate_email(self, res_ids, fields=None):
|
def generate_email(self, res_ids, fields):
|
||||||
multi_mode = True
|
multi_mode = True
|
||||||
if isinstance(res_ids, int):
|
if isinstance(res_ids, int):
|
||||||
res_ids = [res_ids]
|
res_ids = [res_ids]
|
||||||
multi_mode = False
|
multi_mode = False
|
||||||
result = super(MailTemplate, self).generate_email(res_ids, fields=fields)
|
result = super(MailTemplate, self).generate_email(res_ids, fields=fields)
|
||||||
for res_id, template in self.get_email_template(res_ids).items():
|
for res_id in res_ids:
|
||||||
if template.body_type == "qweb" and (not fields or "body_html" in fields):
|
if self.body_type == "qweb" and (not fields or "body_html" in fields):
|
||||||
for record in self.env[template.model].browse(res_id):
|
for record in self.env[self.model].browse(res_id):
|
||||||
body_html = template.body_view_id.render(
|
body_html = self.body_view_id._render(
|
||||||
{"object": record, "email_template": template}
|
{"object": record, "email_template": self}
|
||||||
)
|
)
|
||||||
# Some wizards, like when sending a sales order, need this
|
# Some wizards, like when sending a sales order, need this
|
||||||
# fix to display accents correctly
|
# fix to display accents correctly
|
||||||
body_html = tools.ustr(body_html)
|
body_html = tools.ustr(body_html)
|
||||||
result[res_id]["body_html"] = self.render_post_process(body_html)
|
result[res_id]["body_html"] = self._render_template_postprocess(
|
||||||
|
{res_id: body_html}
|
||||||
|
)[res_id]
|
||||||
result[res_id]["body"] = tools.html_sanitize(
|
result[res_id]["body"] = tools.html_sanitize(
|
||||||
result[res_id]["body_html"]
|
result[res_id]["body_html"]
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,3 +6,4 @@
|
||||||
* Ernesto Tejeda
|
* Ernesto Tejeda
|
||||||
|
|
||||||
* Thomas Fossoul (thomas@niboo.com)
|
* Thomas Fossoul (thomas@niboo.com)
|
||||||
|
* Phuc Tran Thanh <phuc@trobz.com>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
The development of this module has been financially supported by:
|
||||||
|
|
||||||
|
* Camptocamp
|
|
@ -3,7 +3,7 @@
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||||
<title>QWeb for email templates</title>
|
<title>QWeb for email templates</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <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/email_template_qweb"><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-email_template_qweb"><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><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <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/14.0/email_template_qweb"><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-14-0/social-14-0-email_template_qweb"><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/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This module was written to allow you to write email templates in QWeb instead
|
<p>This module was written to allow you to write email templates in QWeb instead
|
||||||
of jinja2. The advantage here is that with QWeb, you can make use of
|
of jinja2. The advantage here is that with QWeb, you can make use of
|
||||||
inheritance and the <tt class="docutils literal">call</tt> statement, which allows you to reuse designs and
|
inheritance and the <tt class="docutils literal">call</tt> statement, which allows you to reuse designs and
|
||||||
|
@ -381,7 +381,8 @@ Furthermore, QWeb views are easier to edit with the integrated ACE editor.</p>
|
||||||
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
|
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
|
||||||
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
|
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
|
||||||
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
|
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
|
||||||
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
|
<li><a class="reference internal" href="#other-credits" id="id6">Other credits</a></li>
|
||||||
|
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -400,7 +401,7 @@ Furthermore, QWeb views are easier to edit with the integrated ACE editor.</p>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
|
<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.
|
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
|
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:%20email_template_qweb%0Aversion:%2013.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:%20email_template_qweb%0Aversion:%2014.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>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
@ -429,16 +430,25 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
</li>
|
</li>
|
||||||
<li><p class="first">Thomas Fossoul (<a class="reference external" href="mailto:thomas@niboo.com">thomas@niboo.com</a>)</p>
|
<li><p class="first">Thomas Fossoul (<a class="reference external" href="mailto:thomas@niboo.com">thomas@niboo.com</a>)</p>
|
||||||
</li>
|
</li>
|
||||||
|
<li><p class="first">Phuc Tran Thanh <<a class="reference external" href="mailto:phuc@trobz.com">phuc@trobz.com</a>></p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="other-credits">
|
||||||
|
<h2><a class="toc-backref" href="#id6">Other credits</a></h2>
|
||||||
|
<p>The development of this module has been financially supported by:</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Camptocamp</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<p>This module is maintained by the OCA.</p>
|
||||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/13.0/email_template_qweb">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/14.0/email_template_qweb">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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,7 +6,7 @@ from odoo.tests.common import TransactionCase
|
||||||
class TestMailTemplateQweb(TransactionCase):
|
class TestMailTemplateQweb(TransactionCase):
|
||||||
def test_email_template_qweb(self):
|
def test_email_template_qweb(self):
|
||||||
template = self.env.ref("email_template_qweb.email_template_demo1")
|
template = self.env.ref("email_template_qweb.email_template_demo1")
|
||||||
mail_values = template.generate_email([self.env.user.id])
|
mail_values = template.generate_email([self.env.user.id], ["body_html"])
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
# this comes from the called template if everything worked
|
# this comes from the called template if everything worked
|
||||||
"<footer>" in mail_values[self.env.user.id]["body_html"],
|
"<footer>" in mail_values[self.env.user.id]["body_html"],
|
||||||
|
@ -14,7 +14,7 @@ class TestMailTemplateQweb(TransactionCase):
|
||||||
% (mail_values[self.env.user.id]["body_html"]),
|
% (mail_values[self.env.user.id]["body_html"]),
|
||||||
)
|
)
|
||||||
# the same method is also called in a non multi mode
|
# the same method is also called in a non multi mode
|
||||||
mail_values = template.generate_email(self.env.user.id)
|
mail_values = template.generate_email(self.env.user.id, ["body_html"])
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
# this comes from the called template if everything worked
|
# this comes from the called template if everything worked
|
||||||
"<footer>" in mail_values["body_html"],
|
"<footer>" in mail_values["body_html"],
|
||||||
|
|
Loading…
Reference in New Issue