OD605 unknown-template¶
A component, a t-inherit or a t-call names a template no indexed bundle defines.
| Category | Severity | Series | Needs the index |
|---|---|---|---|
| Correctness | Error | 17.0 and later | yes |
What it reports¶
A literal static template = "x", or Component.template = "x", on a component of a bundled
script, and the t-inherit="x" or a literal t-call="x" of a template in a bundled XML file under
static/src, when no template file of an indexed bundle registers a t-name="x". An extension
(t-inherit-mode="extension") registers no name, even when it carries a t-name. A template
registered only by a module missing from depends, other than one Odoo always installs such as
web, is reported too.
The t-call on the root of an extension is not read, since Odoo only applies the extension's
children to its parent. What those children add is read. The root of a primary child keeps its
t-call: the child copies its root attributes onto the template it builds.
A t-call on a child of an inheriting template locates an element of the parent, so it is not read
here: OD606 reports it when the parent has none. What that child holds is read. Any
other t-call is read, whatever position it carries: from saas~19.4 on Owl passes that attribute
to the template, and earlier it ignores it.
Why it matters¶
The web client looks templates up by name when it renders a component, and the render fails when
nothing registers the name. A primary template whose parent is missing throws template parent x
not found, and an extension of one is applied to nothing, with only a Missing (extension) parent
templates line in the browser console. Template names
change between series, so a port that keeps an old name breaks the screen at its first render.
The rule stays silent for a module whose dependencies include one that is not indexed, such as an
Enterprise module, which may register the template. A component that only serves as a base, whose
subclasses set a template of their own, is not reported, nor is an empty template on an abstract
component. Templates written inline with xml are not checked, nor is a t-call whose target is
an expression such as {{ x }}. A t-call in a server view is OD311's.
Example¶
<templates>
<t t-inherit="web.ListRenderer.Row" t-inherit-mode="extension">
<xpath expr="//tr[hasclass('o_data_row')]" position="attributes">
<attribute name="class" add="o_highlighted" separator=" "/>
</xpath>
</t>
</templates>
The row template of the list renderer is web.ListRenderer.RecordRow, so the extension applies
to nothing.
<templates>
<t t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension">
<xpath expr="//tr[hasclass('o_data_row')]" position="attributes">
<attribute name="class" add="o_highlighted" separator=" "/>
</xpath>
</t>
</templates>