Browse Source

[ADD] website_mail_qweb

pull/163/head
Holger Brunn 7 years ago
parent
commit
6be2b04996
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 64
      website_mail_qweb/README.rst
  2. 4
      website_mail_qweb/__init__.py
  3. 20
      website_mail_qweb/__openerp__.py
  4. 4
      website_mail_qweb/controllers/__init__.py
  5. 51
      website_mail_qweb/controllers/main.py
  6. BIN
      website_mail_qweb/static/description/icon.png
  7. 4
      website_mail_qweb/tests/__init__.py
  8. 15
      website_mail_qweb/tests/test_website_mail_qweb.py
  9. 18
      website_mail_qweb/views/templates.xml

64
website_mail_qweb/README.rst

@ -0,0 +1,64 @@
.. 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
=========================
Edit QWeb email templates
=========================
This module was written to make Odoo's WYSIWYG email template editor usable for email templates using the QWeb rendering engine.
Usage
=====
To use this module, you need to:
#. click the 'Edit template' button on an email template
#. note that the editor supports designing and translating your templates, but for variable substitutions et al, you'll need to edit the source code of the template
.. 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
Known issues / Roadmap
======================
* the editor has problems with complex template inheritance, this seems rather a problem in Odoo generally than with this specific module
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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Holger Brunn <hbrunn@therp.nl>
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:community@mail.odoo.com>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues.
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.

4
website_mail_qweb/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import controllers

20
website_mail_qweb/__openerp__.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Edit QWeb email templates",
"version": "8.0.1.0.0",
"author": "Therp BV,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Hidden",
"summary": "Glue module to enable the wysiwyg editor for qweb email "
"templates",
"depends": [
'website_mail',
'email_template_qweb',
],
"data": [
'views/templates.xml',
],
"auto_install": True,
}

4
website_mail_qweb/controllers/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import main

51
website_mail_qweb/controllers/main.py

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.addons.website_mail.controllers.email_designer import\
WebsiteEmailDesigner
from openerp import http
from openerp.http import request
class UnquoteObject(str):
def __getattr__(self, name):
return UnquoteObject('%s.%s' % (self, name))
def __repr__(self):
return self
def __call__(self, *args, **kwargs):
return UnquoteObject(
'%s(%s)' % (
self,
','.join(
[
UnquoteObject(
a if not isinstance(a, basestring)
else "'%s'" % a
)
for a in args
] +
[
'%s=%s' % (UnquoteObject(k), v)
for (k, v) in kwargs.iteritems()
]
)
)
)
class Main(WebsiteEmailDesigner):
@http.route()
def index(self, model, res_id, template_model=None, **kw):
result = super(Main, self).index(
model, res_id, template_model=template_model, **kw
)
qcontext = result.qcontext
record = qcontext['record']
if record.body_type == 'qweb':
qcontext['body_field'] = 'body_view_id'
qcontext['mode'] = 'email_designer'
qcontext['object'] = UnquoteObject('object')
qcontext['email_template'] = record
return result

BIN
website_mail_qweb/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

4
website_mail_qweb/tests/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_website_mail_qweb

15
website_mail_qweb/tests/test_website_mail_qweb.py

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import HttpCase
from ..controllers.main import Main
class TestWebsiteMailQweb(HttpCase):
def test_website_mail_qweb(self):
self.authenticate('admin', 'admin')
result = self.url_open(
'/website_mail/email_designer?model=email.template&res_id=%s' %
self.env.ref('email_template_qweb.email_template_demo1').id
)
self.assertIn('Dear object.name,', result.read())

18
website_mail_qweb/views/templates.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="assets_backend" name="website_mail_qweb assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/website_mail_qweb/static/src/js/website_mail_qweb.js"></script>
<link rel="stylesheet" href="/website_mail_qweb/static/src/css/website_mail_qweb.css"/>
</xpath>
</template>
<template id="email_designer" inherit_id="website_mail.email_designer">
<xpath expr="//div[@t-field='record.body']/parent::div" position="after">
<div t-if="body_field == 'body_view_id'" class="col-sm-offset-2">
<t t-call="{{record.body_view_id.id}}" />
</div>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save