Configuration of ‘Search View, Filters and Group by’ in Odoo
Finding the required record/data from hundreds and thousands of records in an ERP software can be a tedious task. But this is not the case with Odoo ERP software. Thanks to the framework options of Odoo, you can search, filter, and group by in Odoo within seconds. It will help you find/search the content that you need and allows you to quickly filter data or groups by a condition to find the right information that you’re looking for.
In Odoo there are different view types. Form View, Kanban View, Tree View, Calendar View, Search View, etc. are some of the different view types available in Odoo. In this blog, we will mainly focus on the features and functionalities associated with Odoo’s ‘Search View’.
Search Views differ from other views because views such as form, kanban, tree, calendar, etc, are associated with the visualization aspect of the data while the search view is used to filter the contents of other views.
The search view is probably the most used view in Odoo and is a powerful aspect that is persistent in every application in Odoo.
In this blog, we will discuss creating a simple search view with filters and groups by options.
The image below shows the ‘Search Area’ in Odoo.
This ‘Search Area’ is a part of Odoo’s default framework and can be seen even in the views associated with your custom modules. This Odoo ‘Search View’ can be customized according to one’s requirements by adding the required fields and conditions to be searched. This can be done by following the example given below.
- Search Option
In order to add the required fields in the ‘Search’ option, we have to add an ‘ir.ui.view’ for the search option. The image below shows an example to add the required fields in the search option.
We can define the required fields to be searched inside the <search> tag as shown above. Here we have added ‘name’, ‘email’, ‘age’, and ‘gender’ under the <search> tag.
The above code will allow you to search for the required fields from the UI interface as shown in the image below. As you type in the search bar, you will see a dropdown menu appear with different options available to help you quickly locate your desired information.
The image below shows the outcome when we use the search option with ‘Name’. Here we have only one record with this name.
We also have the option ‘Filters’ in the Search view. We can filter the records by the fields of the corresponding model. If we click on the ‘Filters’ option, then we can see all the filters corresponding to the model. We can also choose to ‘Add Custom Filter’ from the UI interface but this option is not workable all the time. And hence it is better to define the required filters in the ‘search view’ created in the ‘xml’ file.
The image below shows an example to add the required fields in the filter option.
Here we have added a filter for getting all archived records. A domain should be given for the filter because filtering will be done based on this domain, i.e. here the filter will fetch all the records if the field ‘active’ is ‘False’.
Here we have only one archived record i.e., the ‘active’ field is ‘False’ only for this record. We can also set more than one filter at a time.
We also have the option ‘Group By’ in the Search view. Then we can group the records by the fields of the corresponding model. If we click on the ‘Group By’ option, then we can see all the options available corresponding to the model. We can also choose to ‘Add Custom Group’ from the UI interface but as said earlier, this option is not workable all the time and hence it is better to define the required ‘Group By’ options in the ‘search view’ created in the ‘xml’ file.
The image below shows an example to add the required fields in the group by option.
In the above code, you can see that we are using ‘Gender’ as a ‘Group By’ option. Also, the grouping parameter is passed as a context as shown in the image.
The image above shows the result when ‘Group By – Gender’ is selected. The students are grouped into different groups (here Male and Female).
Similarly, we can also add other fields for grouping.
Using the above example, you can customize the Search, Filter, and Group By options of Odoo. Which will be highly helpful while dealing with large amounts of data.
"Unlock the Full Potential of Your Business with Odoo ERP!"
"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"Get a Free Quote