OD306 tree-renamed-list¶
The tree view type is renamed list.
| Category | Severity | Series | Needs the index |
|---|---|---|---|
| Deprecation | Error | 18.0 and later | no |
What it reports¶
A <tree> element in a view's arch, whether it is the root of a list view or the subview of an
x2many field, and a window action whose view_mode lists tree.
Why it matters¶
Odoo 18.0 renamed the list view type from tree to list, in the arch, in ir.ui.view's type
and in view_mode. A new view whose root is <tree> stops the install with Invalid view type:
'tree'. A demo file differs: see load
failures. An action whose view_mode
still says tree installs, and fails in the browser when someone opens it, because the web client
knows no view of that type. On an ir.actions.act_window.view record, view_mode is a selection
without tree, so the record is refused.
An x2many field's <tree> subview is not taken as a subview: Odoo validates its fields on the
parent model, and refuses one that only the comodel has. When the parent happens to have them all,
the view installs and Odoo appends the comodel's default list, so the inline columns never show.
All of these come from views ported from 17.0 or earlier. Modules of 17.0 and earlier are not
checked, since tree is the only name those series know.
Example¶
<record id="view_partner_category_list_segments" model="ir.ui.view">
<field name="name">res.partner.category.list.segments</field>
<field name="model">res.partner.category</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="parent_id"/>
</tree>
</field>
</record>
<record id="action_partner_segments" model="ir.actions.act_window">
<field name="name">Segments</field>
<field name="res_model">res.partner.category</field>
<field name="view_mode">tree,form</field>
</record>
Both the view's root and the action's view_mode use the name Odoo 18.0 no longer has.
<record id="view_partner_category_list_segments" model="ir.ui.view">
<field name="name">res.partner.category.list.segments</field>
<field name="model">res.partner.category</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="parent_id"/>
</list>
</field>
</record>
<record id="action_partner_segments" model="ir.actions.act_window">
<field name="name">Segments</field>
<field name="res_model">res.partner.category</field>
<field name="view_mode">list,form</field>
</record>
Fixing¶
oscn check --fix renames <tree> to <list>, and each tree of a view_mode to list. A
<tree> stays while a module that is not checked has a <tree> in its inheritance tree, or an
xpath there names tree, as a step, or as a string beside a call to name() or local-name(). A
<tree> spec and a <tree> it may find in its inheritance tree both stay, since --exclude, the
baseline or a file left unwritten could fix one without the other. A <tree> whose name has a
prefix, or comes from a DOCTYPE entity, stays too. A view_mode stays when it also lists list,
which Odoo would refuse as a duplicate, or when its value is not plain text.
See fixing findings.