Enable Dark Mode!
how-to-create-a-search-panel-in-odoo-16.jpg
By: Athul K

How to Create a Search Panel in Odoo 16

Technical Odoo 16

The search panel is one of Odoo's most compelling features. Its main purpose is to provide a filtered view in the simplest and most advanced way based on specific data. You can see the search panel in apps like Lunch and Employee modules.

In the HR module, there is a search panel to the left of Employees,

how-to-create-a-search-panel-in-odoo-16-1-cybrosys

In the search Panel, select based on your filters. Example: In the image above, all conditions are met. Therefore, all employees are displayed based on this condition.

how-to-create-a-search-panel-in-odoo-16-2-cybrosys

Here the image above shows the search panel based on Management.

Additionally, the app displays a search panel. So you can filter the groups with the conditions.

how-to-create-a-search-panel-in-odoo-16-3-cybrosys

This blog explains how to create a search panel in existing modules and custom modules in Odoo 16.

First, check out how to create a search panel for an existing module. For this, we'll make an example by adding a search panel to the purchase module.

XML code:

<odoo>
    <record id="purchase_order_search_panel" model="ir.ui.view">
        <field name="name">request.quotation.search.panel</field>
        <field name="model">purchase.order</field>
        <field name="inherit_id" ref="purchase.view_purchase_order_filter"/>
        <field name="arch" type="xml">
            <search position="inside">
                <searchpanel>
                    <field name="partner_id" enable_counters="1"
                            icon="fa fa-user"/>
                    <field name="user_id" enable_counters="1"
                            icon="fa fa-user"/>
                    <field name="state" limit='5'/>
                    <field name="invoice_status"/>
                </searchpanel>
            </search>
        </field>
    </record>
</odoo>

Here we add a search panel based on the three fields of the purchase order. This is based on invoice status, status, and vendor. You can also add fields here. The attribute is used in the search panel along with the name field.

One: By default, only one value can be selected at a time. many2one and selection are types of fields.

Name: Filter field name (required field). Filtering is done based on this field. For example, if partner_id is the field specified in the search field, you will see filtering based on the partner.

Icon: Option to choose an icon for displaying the string.

Limit: Determines the maximum number of records to retrieve for a field.

Enable_counters: If checked, the number of records for each value will be displayed. Zero by default.

The output looks like this:

how-to-create-a-search-panel-in-odoo-16-4-cybrosys

Similarly, In the custom module.

<odoo>
  <record id="custom_module_search_panel" model="ir.ui.view">
        <field name="name">custom.module.search.panel</field>
        <field name="model">custom.model(model name)</field>
        <field name="inherit_id" ref="module_name.search_view"/>
        <field name="arch" type="xml">
            <search position="inside">
                <searchpanel>
         <!-- fields-->
                </searchpanel>
            </search>
        </field>
    </record>
</odoo>

This search panel is primarily used to easily filter out objects of interest. You can add any field to any model, whether it's a custom module or an existing one. The search panel can be made more attractive by using nice icons and fonts. It is mainly a unique creation method.


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