Tuesday, September 2, 2025
1 change · master
Enhancements to existing features
This update modernizes Odoo's page and report template engine so reusable templates receive inputs more clearly and render content only when needed. This should make website, portal, email, reporting, payment, survey, event, manufacturing, and localization pages more predictable and easier to maintain, with potential efficiency gains from streaming rendering.
Original PR description
This commit introduces major improvements to QWeb: parametric `t-call`, lazy XML evaluation. ### 1. Parametric `t-call` Previously, parameters passed to a template through `t-call` were defined…
This commit introduces major improvements to QWeb: parametric `t-call`,
lazy XML evaluation.
### 1. Parametric `t-call`
Previously, parameters passed to a template through `t-call` were defined
inside the `t-call` tag using `t-set` elements. The content inside the `t-call`
was evaluated within the context of the called template.
Now, `t-call` becomes **parametric**:
- Parameters are passed directly as **attributes** on the `t-call` tag instead
of using internal `t-set` definitions.
- The content inside the `t-call` tag no longer has access to these parameters;
it only sees the variables available **before the `t-call`**.
- The attributes passed to `t-call` are used **only for rendering the called
template** and **not** for the content inside the `t-call`.
**Example before:**
```xml
<t t-call="my_template">
<t t-set="custom" t-value="x + y" />
<t t-set="add_class" t-valuef="o_toto_{{stuff}}" />
<t t-set="title">Hello <t t-out="user.name"/></t>
</t>
```
**Example after:**
```xml
<t t-call="my_template"
custom="x + y"
add_class.f="o_toto_{{stuff}}"
title.translate="Hello {{user.name}}" />
```
### 2. Lazy XML evaluation & streamable rendering
QWeb now supports **lazy XML evaluation**:
- All XML content is now **lazy** and only evaluated **when explicitly
rendered**, typically when using `t-out`.
- This also applies to XML content declared **inside `t-call` blocks**: the
content is generated **only when actually output**.
- The variables available for evaluation are those present **at the time the
content was declared**, not when it is rendered.
- As a result, **QWeb templates are now streamable**, allowing more efficient
and predictable rendering.
### Impact
- Simplifies and clarifies `t-call` usage.
- Prevents unexpected side effects on local contexts.
- Enables **lazy evaluation** and **streamable QWeb rendering**.
- Support translatable formated string on `t-call` parameters.
- Improves predictability, and maintainability of QWeb templates.
### NB
`t-call` on other element than <t> is now forbidden.
The parametric t-call change is backward compatible (the stream is apply for t-call with attributes/params or t-call that does not contains t-set), the old semantics will be deprecated in 19.1 (with a log warning).
The new versions are the ones with attributes (not prefixed with t-*) on the t-call tag.