Integrated Tech Solutions

How to create Filters & Groups in Odoo16

By - Admin June 28, 2023

To create filters in Odoo, you need to define domain expressions in the corresponding model’s view. Here’s a step-by-step guide on how to create filters in Odoo:

Step 1: Identify the model and view Determine the model and view where you want to add the filters. For example, let’s say we want to add filters to the “sale.order” model’s tree view.

Step 2: Define the filters in the view Open the XML file corresponding to the view you identified in the previous step. Within the <tree> tag, add <filter> elements to define the filters. Each <filter> element represents a filter option with a name, domain, and string (display label). Here’s an example:

<record id="view_sale_order_tree_inherit" model="ir.ui.view">
    <field name="name">sale.order.tree.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_tree"/>
    <field name="arch" type="xml">
        <tree>
            <filter name="pending_orders" string="Pending Orders" domain="[('state', '=', 'draft')]"/>
            <filter name="confirmed_orders" string="Confirmed Orders" domain="[('state', '=', 'sale')]"/>
            <filter name="paid_orders" string="Paid Orders" domain="[('payment_status', '=', 'paid')]"/>
        </tree>
    </field>
</record>

In this example, we’ve added three filters: “Pending Orders,” “Confirmed Orders,” and “Paid Orders.” Each filter has a unique name, a display label (string), and a domain expression that defines the records to be displayed when the filter is selected. The domain expression is specified within the domain attribute.

Step 3: Update the module After making the changes, update your Odoo module and restart the Odoo server. You can do this by upgrading the module or restarting the server, depending on your deployment.

Once the module is updated and the server is running, the filters should appear in the specified view. Clicking on a filter option will apply the corresponding domain expression and filter the records accordingly.

Note: This is a basic example to demonstrate the concept of filters in Odoo. You can customize the domain expressions and filter options according to your specific requirements.

Keep Reading

👋 Hi, Find this Helpful? There is More

You Asked,
We made it!

fix japanese keyword hack

Step by Step Video Tutorials on trending topics in software development

Yes I am Curious »

5 Tips to Pick the Most Engaging Live Chat for Your Website

In today’s fast-paced digital world, providing excellent customer service is a key differentiator for businesses. One of the most effective...

Know More »
next js deployed on aws

Beginners Guide to deploy NextJs App on AWS EC2 Server

In this blog post, we will walk you through the step-by-step process of deploying a Next.js application on an AWS...

Know More »