Learn – How to create a Search View in Odoo 8 to12 with Example

Greetings Everyone,

In this blog-post tutorial, you will learn how to create a Search View in an Odoo 8 / 9 / 10 /11 / 12 module.

What is Search View in Odoo?

  • A search view defines the search options that will be available in the views.

Which search options are available in Search View?

  • Define the ‘fields’ to be searched when a user types in the search box.
  • Set Predefined Filters.
  • Data Grouping options.

Example of a Search View :-

Earlier in my previous blog-post, I had created a Model to collect student’s information. Then I had created its From View and Tree View. Now I will create a Search View for the student model.

Code for creating a Search View

 

Steps for creating Search View in Odoo

  • Add all the fields that you want to search when a user types in the search box. Here, I have added ‘name’, ’email’, ‘contact’ as searchable fields.
  • To add a Group By filter, add the field as a value in the ‘context’ dictionary with key ‘group_by’. Here, I have added Group by for ‘Course’, ‘Year’ and ‘Month’ .
  • To add a Domain Filter, add your domain in the ‘domain’ attribute. Here, I have added Domain Filter for ‘Physically Disabled’ and ‘Current Year’. By seeing the code you will come to know how to write your own domain.

SnapShot of Eclipse IDE:-

Search View Code Odoo 8
Search View Code Odoo – Click to Enlarge

 

Search Box Odoo 8
Search Box Odoo

 

Group By and Domain Filters Odoo 8
Group By and Domain Filters Odoo – Click to Enlarge

 

Hope you learned how to create a Search View in Odoo module in this tutorial, your reviews/comments/suggestions/doubts are most welcomed, please comment in the section below, and subscribe to the newsletter to receive timely future updates of this blog.

Thank You.

Having 5+ years of experience working on Odoo with projects covering several business verticles like Retail industry, Manufacturing, Service, Rental, Education, Medical and many more.

Post Author: Burhan Vakharia

Having 5+ years of experience working on Odoo with projects covering several business verticles like Retail industry, Manufacturing, Service, Rental, Education, Medical and many more.

1 thought on “Learn – How to create a Search View in Odoo 8 to12 with Example

    sehrish

    (September 3, 2019 - 10:24 am)

    great sharing thanks……...

Leave a Reply

Your email address will not be published. Required fields are marked *