Creating tree views (now called list views) in Odoo 19 is essential for displaying and managing multiple records efficiently. This guide provides a practical approach using a Patient Management System example.
List views serve as the primary interface where users interact with business data daily—from managing patient records and inventory items to analyzing sales orders and financial reports. In any ERP system, the ability to quickly scan, filter, search, and manipulate large datasets becomes a competitive advantage that significantly improves operational efficiency and reduces training overhead.
Let's Start: Creating the Patient Model
To demonstrate Odoo 19 list views effectively, we'll create a comprehensive Patient Management model. This model will include various field types and relationships that showcase the full power of modern list view features like priority widgets, status badges, and user avatars.
Create the Model
First, create your patient model in models/patient.py:
from odoo import models, fields, api
class PatientManagement(models.Model):
_name = 'patient.management'
_description = 'Patient Management System'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'patient_id desc'
sequence = fields.Integer(string='Sequence')
patient_id = fields.Char(string='Patient ID', required=True, default='New')
name = fields.Char(string='Full Name', required=True, tracking=True)
age = fields.Integer(string='Age', compute='_compute_age', store=True)
gender = fields.Selection([('male', 'Male'), ('female', 'Female')], string='Gender')
phone = fields.Char(string='Phone Number')
email = fields.Char(string='Email Address')
blood_group = fields.Selection([
('a+', 'A+'), ('a-', 'A-'), ('b+', 'B+'), ('b-', 'B-'),
('ab+', 'AB+'), ('ab-', 'AB-'), ('o+', 'O+'), ('o-', 'O-')
], string='Blood Group')
status = fields.Selection([
('active', 'Active'), ('inactive', 'Inactive'), ('archived', 'Archived')
], string='Status', default='active', tracking=True)
priority = fields.Selection([
('0', 'Low'), ('1', 'Normal'), ('2', 'High'), ('3', 'Very High')
], string='Priority', default='1')
assigned_doctor = fields.Many2one('res.users', string='Assigned Doctor')
tag_ids = fields.Many2many('patient.tag', string='Tags')
Create the List View
Create your list view in views/patient_views.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="view_patient_management_list" model="ir.ui.view">
<field name="name">patient.management.list</field>
<field name="model">patient.management</field>
<field name="priority">1000</field>
<field name="arch" type="xml">
<list class="o_patient_management"
string="Patient Management"
sample="1"
decoration-success="status == 'active'"
decoration-muted="status == 'inactive'"
decoration-danger="priority == '3'"
decoration-warning="priority == '2'">
<!-- Header with bulk actions -->
<header>
<button string="Send Reminders"
name="action_send_reminders"
type="object"
class="btn-secondary"/>
<button string="Mark as Active"
name="action_mark_active"
type="object"
class="btn-primary"/>
</header>
<!-- Hidden fields for decorations -->
<field name="sequence" widget="handle"/>
<field name="priority" column_invisible="True"/>
<field name="status" column_invisible="True"/>
<!-- Visible fields -->
<field name="patient_id" string="Patient ID" decoration-bf="1"/>
<field name="name" string="Patient Name" decoration-bf="1"/>
<field name="age" string="Age" optional="show"/>
<field name="gender" string="Gender" optional="show"/>
<field name="phone" string="Phone" optional="show"/>
<field name="blood_group" string="Blood Group" optional="show"/>
<field name="assigned_doctor" widget="many2one_avatar_user"
string="Doctor" optional="show"/>
<field name="tag_ids" widget="many2many_tags"
options="{'color_field': 'color'}" optional="show"/>
<field name="activity_ids" widget="list_activity"
optional="show"/>
<field name="priority" widget="priority" string="Priority"/>
<field name="status" widget="badge" string="Status"/>
</list>
</field>
</record>
</data>
</odoo>
Below you can see the complete list view implementation for our Patient Management system:
-view-in-odoo-19-01.png)
Key Features Explained
- Enhanced Column Management: The new column_invisible attribute and sophisticated optional field controls give users unprecedented flexibility over their data display. Users can personalize views by showing or hiding columns based on their specific roles and responsibilities, creating focused interfaces that reduce screen clutter and improve productivity.
- Advanced Visual Feedback: The enhanced decoration system provides intelligent color coding through multiple decoration attributes—decoration-success, decoration-danger, decoration-warning, and decoration-info—allowing users to quickly identify priority items, urgent tasks, or status changes at a glance.
- Intelligent Widget Integration: Modern widgets like many2one_avatar_user for user representation, list_activity for activity tracking, many2many_tags with color support, and badge widgets for status display transform static data into interactive, meaningful visual elements.
- Revolutionary Drag & Drop: One of the most exciting additions is native drag-and-drop functionality within list views. Users can reorder records, reorganize priorities, and move items between categories without opening individual forms, making data management more intuitive than ever.
- Powerful Bulk Operations: The enhanced header section supports comprehensive bulk actions, enabling users to perform operations on multiple records simultaneously—from sending appointment reminders to updating statuses across hundreds of records.
- Mobile-First Design: Built with responsive principles, Odoo 19 list views automatically adapt to different screen sizes, ensuring seamless functionality across desktops, tablets, and smartphones.
Let's Check New Features in Odoo 19 List View
Smart Group Management
In Odoo 19, managing grouped records is now intuitive. Click the action menu of any group header to edit the grouping field directly - no need to open separate forms.
-view-in-odoo-19-02.png)
Quick Group Creation
When your list view is grouped by default, simply click the "Add new..." link at the bottom to create new groups instantly. Perfect for adding project stages or status categories on the fly.
-view-in-odoo-19-03.png)
Enhanced Drag & Drop
Drag and drop now works between groups! Move patients between "Active" and "Inactive" status, or reorganize records across different categories seamlessly.
-view-in-odoo-19-04.png)
Auto-Resize Columns
Double-click any column border and Odoo 19 automatically adjusts all column widths for optimal display. No more manual column resizing!
-view-in-odoo-19-05.png)
These small but powerful improvements make list views more interactive and user-friendly, reducing clicks and saving time in daily operations.
To read more about How to Create a List View Attributes in Odoo 18, refer to our blog How to Create a List View Attributes in Odoo 18.
FAQ Section
Q: How do I hide fields from specific user groups?
A: Use the groups attribute: <field name="field_name" groups="base.group_system"/> to show fields only to system administrators.
Q: Can I make list views editable inline?
A: Yes, add editable="top" or editable="bottom" to the <list> tag to enable inline editing.
Q: How do I add custom CSS to my list view?
A: Use the class attribute in the list tag: <list class="my_custom_class"> and add CSS in your module's static files.
Q: What's the purpose of the sample attribute?
A: sample="1" shows sample data when the list is empty, helping users understand the view structure.
Q: How do I limit the number of records displayed?
A: Add limit="50" to the <list> tag to show only 50 records per page.
Q: How do I implement multi-selection in list views?
A: List views support multi-selection by default. Users can select multiple records using checkboxes and perform bulk actions.
Q: What are decoration attributes and how many can I use?
A: Decoration attributes provide visual feedback based on field values. You can use multiple decorations like decoration-success, decoration-danger, decoration-warning, and decoration-info simultaneously.
Q: How do I troubleshoot XML syntax errors in list views?
A: Common issues include unescaped XML characters (&, <, >). Use &, <, and > respectively. Also ensure proper tag closing and attribute quoting.