Join the Odoo Inner Circle to view the premium video below.
Learn to Customize Search Views in Odoo
Introduction: Learn to create customized search views in Odoo
Examine how the Odoo search works and how it can be customized
Activating developer mode to better examine the Odoo search framework
Understanding the default search and learn how to remove it from the search view
Adding a new search option and domain filter to an existing search view
Understanding how to utilize AND/OR conditions in Odoo's search
Adding a custom field to our model and then including it in a custom search
Learn how to add additional criteria, fields and options to the default search

Learn to Customize Search Views in Odoo

Odoo Inner Circle Only

This Odoo development video covers one of the most common Odoo customization requests... customizing Odoo search views in one of the most effective ways to increase application usability and better fit Odoo with existing business requirements.

Video Length:   42 minutes
Free With Odoo Inner Circle

Learn to customize Odoo's powerful search capabilities

One of the greatest features of Odoo is the ability to easily search and find the records you are looking for. Even better, Odoo's powerful search view framework allows you to customize the search features in Odoo to better fit business requirements. Perhaps more than any area related to Odoo customization and Odoo Development, the ability to define custom search views and filters on your records will have a profound impact making Odoo integrate smoothly into a business.

Understanding Odoo's search view architecture

In this video we explore in great detail the search view architecture in Odoo. Learn how you can expand the built in search options to include fields beyond those included in the default Odoo installation. Create a custom field on your form and learn how you can include that new custom field within the users available search options. Odoo also allows you to define custom groupings and even set default filters to be applied.

Essential Odoo customization to meet business requirements

If you are interested in Odoo there is a good chance that the ability to customize Odoo to meet business requirements is a primary reason. The ability to define custom search criteria is critical to many customization efforts. As the number of records in a system grows from dozens, to hundreds to perhaps even hundreds of thousands of records; the ability to create smart filters that help the user find the records they are looking for can make the difference between a frustrating and awkward system to use and great easy to use system that makes it easy for users to find the records they are looking for.

What are search views in Odoo?

Whenever you are on a tree view, kanban view, or other view that can be searched Odoo uses an XML Search View definition to determine exactly how the search in Odoo should function for that specific model. For example, in the Sales Order tree view there are specfic options that will help you in locating a sales order in Odoo.

Here we can see how you have options to search by customer, salesperson, sales team, contract, or product. You can also see as we have expanded the search options that we have filters to restrict sales orders to only my sales orders, quotations, sales, To Invoice, Done, and New Mail.  The Group By options that are available are also defined in the search view as well.

Do I have to know how to develop modules to customize search views?

This depends on exactly what you wish to do with your search views. Fortunately it is very easy to add extra fields you may wish to search for or remove options that are not appropriate for your specific business requirements. If however you wish to create specialized searches that are more complex it is possible you may need to write custom python code to meet your objects. Most often however you can accomplish most tasks by modifying the search views without the necessity of creating a module.

What is the basic format of a search view in Odoo?

Search views are stored in XML and are quite readable for someone with basic knoweldge of XML. Below is the basic search view:

<?xml version="1.0"?>
<search string="Search Sales Order">
                    <field name="name" string="Sales Order" filter_domain="['|',('name','ilike',self),('client_order_ref','ilike',self)]"/>
                    <field name="partner_id" operator="child_of"/>
                    <field name="user_id"/>
                    <field name="section_id" string="Sales Team" groups="base.group_multi_salesteams"/>
                    <field name="project_id"/>
                    <field name="product_id"/>
                    <filter string="My" domain="[('user_id','=',uid)]" name="my_sale_orders_filter"/>
                    <filter string="Quotations" name="draft" domain="[('state','in',('draft','sent'))]" help="Sales Order that haven't yet been confirmed"/>
                    <filter string="Sales" name="sales" domain="[('state','in',('manual','progress'))]"/>
                    <filter string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/>
                    <filter string="Done" domain="[('state','=','done')]" help="Sales Order done"/>
                    <filter string="New Mail" name="message_unread" domain="[('message_unread','=',True)]"/>
                    <group expand="0" string="Group By">
                        <filter string="Salesperson" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Customer" domain="[]" context="{'group_by':'partner_id'}"/>
                        <filter string="Order Month" domain="[]" context="{'group_by':'date_order'}"/>

Each element tells the Odoo engine exactly what options are available in the search.

Why would I want to modify the search views in Odoo?

As the number of records grow within your system, your users will spend more and more time finding the records they need to complete a given task. When you only have a few dozens sales orders in the system then locating data is not a problem. But as the data grows having search functions that make it easy for users to find records becomes more critical. Perhaps more than any other customization option within Odoo, the abiltity to customize search views has perhaps the greatest potential to improve user satisfaction and safe time in using the system. 

What will I learn in this video?

In this video we demonstrate how to customize search views in several ways. We start with the basics of adding fields to the list of searchable fields and defining new search criteria. Next we begin to look at how default filters work and how domains within an action can effect the results of your search view. We look into the use of separators to create AND and OR options within your search views. Finally we look at a more complete example from scratch... adding an entirely new field to the model then including that in a customized search view.