In Odoo 18, the search panel is a powerful tool that allows users to filter and navigate records within a module more effectively. This feature provides a user-friendly interface that enables quick access to key data based on specific criteria without needing to rely solely on the traditional search bar or advanced filters. Implementing a search panel can significantly enhance the user experience, especially when managing large volumes of data.
What is a Search Panel?
The search panel in Odoo allows users to view predefined categories (filters) and navigate through them directly within the view. The categories can be based on any field in the model, including many-to-one, many-to-many, or selection fields, making it easy to filter data based on those fields without additional clicks.
The search panel is typically positioned on the left-hand side of the screen, providing a simple interface where users can toggle between different filters.
Steps to Create a Search Panel in Odoo 18
We can implement a search panel for the product model.
Here is an example of the XML code for the search panel:
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="product_template_search_panel" model="ir.ui.view">
<field name="name">product.template.search.panel</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<search position="inside">
<searchpanel>
<field name="categ_id" icon="fa-filter" string="Category" select="multi"/>
<field name="type" icon="fa-files-o"/>
</searchpanel>
</search>
</field>
</record>
</odoo>
This XML code defines a search panel for the product.template model in Odoo. It customizes the search view by inheriting from an existing search view (product.product_template_search_view) and adding a search panel that allows filtering products based on their category (categ_id) and type (type). The search panel also includes icons to visually represent the filters (fa-filter for category and fa-files-o for type). The select="multi" option for categ_id allows selecting multiple categories at once.
This is the result:
The search panel is a highly useful feature in Odoo 18 for modules that handle a significant amount of data. By using the search panel, you can streamline the way users access and filter information, improving the overall user experience and making navigation more intuitive. Implementing it in your module is straightforward, and with the flexibility provided by Odoo, you can customize it according to your specific needs.
To read more about How to Create a Search Panel in Odoo 17, refer to our blog How to Create a Search Panel in Odoo 17.