Adding list and search views
When viewing a model in list mode, a <tree>
view is used. Tree
views are capable of displaying lines organized in hierarchies, but most of the time they are used to display plain lists.
We can add the following tree view definition to todo_view.xml
:
<record id="view_tree_todo_task" model="ir.ui.view"> <field name="name">To-do Task Tree</field> <field name="model">todo.task</field> <field name="arch" type="xml"> <tree colors="gray:is_done==True"> <field name="name"/> <field name="is_done"/> </tree> </field> </record>
We have defined a list with only two columns, name
and is_done
. We also added a nice touch: the lines for done tasks (is_done==True
) are shown in grey.
At the top right of the list Odoo displays a search box. The default fields it searches for and available predefined filters can be defined by a <search>
view.
As before, we will add this to the...