The List View is a fundamental view in Odoo used to display a collection of records in a tabular format. This view provides a quick overview of the data and allows users to perform various actions such as searching, sorting, and filtering. In Odoo 18, the <list>
tag has replaced the <tree>
tag to better align with the function of this view.
Anatomy of a List View
Generally, a List View consists of:
- Header: The top section of the List View that displays the names of the columns or fields being shown.
- Data Rows: Each row represents a single record or data entry.
- Actions: Buttons or menus that enable users to perform actions on specific records, such as editing, deleting, or opening the form view.
- Pagination: A feature that allows users to navigate between different pages if the amount of data is large.
- Search Bar: A search box that enables users to search for records based on specific keywords.
Detailed Explanation
- Fields: Each column in the List View corresponds to a field in the data model. You can specify which fields to display and their respective view types (e.g., text, date, boolean).
- Filters: The filter feature enables users to narrow down the data based on specific criteria. You can define the available filters in the List View.
- Grouping: The grouping feature allows you to categorize data based on the values of specific fields.
- Actions: Actions that can be performed on records, such as editing, deleting, or opening the form view. These actions can be defined using XML.
Code Example
Here's a sample XML code snippet to create a simple List View in Odoo 18 using the <list>
tag:
<odoo>
<data>
<record id="view_partner_list" model="ir.ui.view">
<field name="name">partner.list</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<list>
<field name="name"/>
<field name="email"/>
<field name="phone"/>
</list>
</field>
</record>
</data>
</odoo>
This code will generate a List View for the res.partner
model (partners) with the columns name
, email
, and phone
.
Customizing List Views
You can customize List Views in various ways, such as:
- Modifying the appearance: You can change the appearance of fields using the
widget
attribute on the field tag. - Adding actions: You can add custom actions using the
<field name="action">
tag within the<list>
tag. - Using templates: You can use templates to create more complex List View designs.