odoo/odoo#77074
Created by Editor, Nicolas Bayet (nby)
Statuses:
- legal/cla: Contributor License Agreement check
- ci/runbot: Odoo Test Suite
- ci/upgrade_enterprise: Test upgrades for enterprise master
- ci/template: Contact runbot team for help in case of failure.
- ci/style: Optional style check. Ignore it only if strictly necessary.
- ci/security: Overridden by @xmo-odoo
- label
- odoo-dev:saas-14.5-qweb-template-nby
- head
- f164d108268423ebb4c2b58d8f98d927e1d92b9b
- merged
- 4 years ago by Marketing, Thibault Delavallee (tde)
odoo/odoo | odoo/enterprise | |
---|---|---|
saas-14.5 | #77074 | #21127 |
15.0 | ||
16.0 | ||
17.0 | ||
18.0 | ||
saas-18.1 | ||
saas-18.2 | ||
saas-18.3 | ||
master | #77377 | #21246 |
[MERGE] mail, various: use QWeb in mail templates
RATIONALE
Jinja is used a templating engine in various places, notably in mail templates
and digest content. It is known to have some limitations
- its syntax is specific and is concurrent with Odoo QWeb template language.
Additional knowledge is required just for that purpose; - it is not XML compliant, meaning we quickly run into issues when editing
its content as HTML. Notably rendering engine (browsers) may reorder
jinja content arbitrary when its syntax is not valid, which is often
the case with advanced constructs involving nested for and if; - jinja template do not benefit from improvements done in QWeb and its
integration in our HTML editor; - it is an outside templating engine that we do not control;
- it adds an external dependency;
PURPOSE
Replace Jinja with Qweb so that we can now build tools to edit a Qweb
template, mainly for mail.template
records. In this merge we now
support QWeb as rendering engine for mail templates. All templates are
updated accordingly. Some other records using jinja are also updated like
digest
content (tips).
To be able to edit template content from the backend interface a plugin to
the Odoo editor has been made to seamlessly edit documents. It includes :
* allow to make dynamic variables (eg. <t t-out="variable"/>
) not
editable when required;
* group and hide related logical branching (ie. t-if, t-elif and t-else)
in order to see only one at once;
* a floating select input to switch visibility of a particular logical
branching;
TEXT RENDERING
Not all content previously rendered using jinja holds HTML content. For
example some email fields (e.g. email_from
or subject
) used Jinja
syntax for rendering (e.g. Email for ${object.name}
or
${object.email_formatted | safe}
).
We want to keep dynamic rendering for those char fields. However as it is
not XML we use a new rendering engine called "inline_template". It is
based on QWeb rendering used to evaluate expression and attributes like
t-att-href="{{object.link}}"
. Expressions should be enclosed by {{
and
}}
to highlight they are dynamic. For most expressions this is equivalent
to jinja expressions with a simple marker change.
LINKS
task-2497930 (Main editor task)
task-27033 (Main functional task)