Apr
24
2016

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

Greetings Everyone,

In this blog-post tutorial, you will learn how to create a Search View in an Odoo 8 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 8 – Click to Enlarge

 

Search Box Odoo 8

Search Box Odoo 8

 

Group By and Domain Filters Odoo 8

Group By and Domain Filters Odoo 8 – Click to Enlarge

 

Hope you learnt 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.

Share This!
Share On Twitter
Share On Linkdin
Contact us

Related Posts

About the Author: Burhan Vakharia

I, Burhan Vakharia, am a python developer, CS Lover living in Gandhinagar, Gujarat, India. I have a degree in Computer Science and Engineering from Babaria Institute of Technology. I am currently working as Odoo Developer at Serpent Consulting Services Pvt. Ltd., Gandhinagar. Apart form Odoo Framework, i have worked on C# .Net and Android Platforms.

Leave a comment

Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Contact us
Hide Buttons