Hello Odooers & Developers!
Welcome to another helpful article about Odoo! This post will discuss one of the most valuable features of the Odoo interface Search Views. We’ll also look at how to use Filters, the Search Panel, and Group By options.
The search feature in Odoo makes it easy for users to find, filter, and organize records quickly. Whether creating a new app or customizing an existing one, learning to use Search Views will make your module more user-friendly and powerful.
What You Will Learn in This Guide
- What is a Search View in Odoo?
- How to Add Search Fields
- How to Use Filters
- How to Group Data
- How to Add a Search Panel
What is a Search View in Odoo?
A Search View in Odoo is a special type that appears at the top of the list, as well as kanban and pivot views. It allows users to quickly search and filter records and group them by certain fields. It allows users to:
- Search using fields
- Filter results
- Group records
- Access a sidebar with categories (Search Panel)
How to Create a Search View in Odoo
Let’s say we have a custom model called odoo.lessons. We'll now define a search view that allows users to search by name, trainee, price, and filter by status.
Add the following XML code to your module’s view file to define the Search View:
XML
<odoo>
<record id="view_dev_learn_odoo_search" model="ir.ui.view">
<field name="name">view.dev.learn.odoo.search</field>
<field name="model">odoo.lessons</field>
<field name="arch" type="xml">
<search>
<!-- Search Fields -->
<field name="name"/>
<field name="trainee_id"/>
<field name="lesson_price"/>
<!-- Filters -->
<separator string="Status"/>
<filter string="Draft" name="draft" domain="[('state','=','draft')]"/> <filter string="In Process" name="in_process" domain="[('state','=','in_process')]"/>
<filter string="Done" name="done" domain="[('state','=','done')]"/>
<!-- Group By Options -->
<group expand="0" name="group_by" string="Group By">
<filter name="trainee_id" string="Trainee" domain="[]" context="{'group_by': 'trainee_id'}"/>
<filter name="state" string="State" domain="[]" context="{'group_by': 'state'}"/>
<filter name="lesson_price" string="Lesson Price" domain="[]" context="{'group_by': 'lesson_price'}"/>
</group>
<!-- Search Panel (Sidebar) -->
<searchpanel>
<field name="state" icon="fa-check-circle"/>
<field name="trainee_id" icon="fa-folder"/>
</searchpanel>
</search>
</field>
</record>
</odoo>
This blog will help you understand how Search Views and Filters work in Odoo and how you can use them to make it easier for users to find, filter, and organize records in your app.
These fields appear in the search bar for keyword-based searching.
We define all the search options inside the <search> tag in the XML file. Within this tag, we list the fields we want users to be able to search with.
For example, if we include fields like name, trainee_id, and lesson_price, users can search for lessons based on these details.
We get search results based on the values entered in these fields.
Filters allow users to narrow down records based on specific conditions quickly.
For Example:
Users can click these options to view records with that specific status if we add filters like Draft, In Process, and Done.
This filter will show only the records where the state is set to draft.
Group By lets users organize data into groups based on a specific field. It makes it easier to analyze records.
For Example:
If you group by Trainee, you'll see lessons grouped by each Trainee.
This groups the search results by the trainee_id field.
The Search Panel is a sidebar on the left side of list views. It shows clickable categories that help users filter data visually.
For Example:
This creates a side panel with options based on state and trainee. Clicking on them filters the records accordingly.
Conclusion :
The Search View in Odoo helps users easily find, filter, and organize records. It's beneficial when dealing with lots of data.
By adding:
- Search Fields – to search by specific details
- Filters – to quickly show certain records
- Group By – to group similar records
- Search Panel – to filter using a sidebar
If you want odoo technical training on any odoo version , please let us know by mail at odoo@devintellecs.com. Then next, our odoo expoert will conduct online or offline training with you
Devintellecs & team are odoo training providers in the USA and INDIA, so we will try our best to give the training either individal or any bulk employee company.
If you want to check your odoo technical or functional knowledge, then we have prepared the odoo EXam practice test for the odoo technical & functional people.