Enable Dark Mode!
how-to-configure-search-view-filter-group-by-in-odoo-17.jpg
By: Ayana KP

How to Configure Search View, Filter & Group by in Odoo 17

Technical Odoo 17

Odoo 17, a robust open-source business management platform, offers powerful tools for organizing and retrieving data efficiently. In this blog post, we'll delve into the intricacies of configuring search views, filters, and groups in Odoo 17, empowering users to tailor their experience and streamline their workflows.

1. Create a Search View

Search views in Odoo allow users to define specific criteria and conditions to narrow down their search, making it easier to find relevant information. Here's a more detailed explanation of search views in Odoo:

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

The highlighted section represents the search view functionality in Odoo 17. In this context, we can include the names of fields within the search view, enabling users to search for specific criteria.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

When a search is performed, the results are generated based on the corresponding field names. Let's explore the process of creating a Search View in Odoo 17. Similar to Form, Tree, and Kanban views, a search view can be incorporated into an XML file located within the views folder.

<record id="view_search_custom" model="ir.ui.view">
    <field name="name">Custom Search View</field>
    <field name="model">your.module.model</field>
    <field name="arch" type="xml">
        <search>
             <field name="name"/>
             <field name="email"/>
        </search>
    </field>
</record>

Within the <search> tag in Odoo XML configuration, we establish the parameters for search views. In this context, we designate specific field names. Consequently, when users initiate searches using these defined fields, the system generates results tailored to the criteria specified in these fields. This approach provides a structured and user-friendly means of retrieving relevant information based on the identified search parameters.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

2. Filters and Group By Options

In the Search view, we have Filters and Group By options to refine and organize records based on the model's fields. Clicking on these options shows predefined filters. However, consistently adding custom filters or groups can be a bit tricky, requiring extra effort.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

By clicking on the dropdown menu, as shown in the image above, we can navigate to the filters and group by sections. Look at the screenshot below.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

We can easily set up default filters. Let's see how it's done.

<record id="model_id_view_search" model="ir.ui.view">
        <field name="name">model.id.view.search</field>
        <field name="model">model_id</field>
        <field name="arch" type="xml">
            <search>
                <field name="field1"/>
                <field name="field2"/>
                <filter string="Archived" name="active" domain="[('active', '=',False)]"/>
            </search>
        </field>
    </record>

Here, we created a filter to show all archived records. If the 'name' is required, you can use any name. It's important to set a rule (domain) for the filter, which, in this case, makes it display records where the 'active' field is false.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

For Group By, you can specify the filters within the group tag.

<record id="model_id_view_search" model="ir.ui.view">
        <field name="name">model.id.view.search</field>
        <field name="model">model.id</field>
        <field name="arch" type="xml">
          <search>
            <field name="name"/>
            <field name="email"/>
            <field name="active"/>
            <filter string="Archived" name="active" domain="[('active', '=', False)]"/>
            <group expand="0" string="Group By">
               <filter string="Company" name="company_id" context="{'group_by': company_id}"/>
            </group>
          </search>
       </field>
</record>

In the code, we're grouping data by the company_id field and passing information using the context. Just like 'name' is necessary, we're choosing to group records based on the company_id field. You can use any field from the model for grouping.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

When we group records by company_id, we see all the records in the company.

how-to-configure-search-view-filter-group-by-in-odoo-17-cybrosys

This grouping method can be applied to other fields too, giving us a customized way to search for information.

Configuring search views, filters, and group by options in Odoo 17 is essential for optimizing data exploration and management. By following these steps, users can tailor their Odoo experience, making it more efficient and aligned with their specific business needs.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message