How to Add a Custom Filter in Odoo

how to add a custom filter in odoo

In modern ERP solutions like Odoo, the views play a crucial role in simplifying complex workflows. Whether you’re managing tasks in a project, tracking opportunities in CRM, or handling support tickets, Kanban boards and other views help you visualize progress at a glance. However, to truly make them powerful, you need to tailor the interface to your users’ exact needs. That’s where custom filters come in.

As an experienced Odoo developer and consultant, I often get asked: “How can we add a custom filter in odoo to improve user experience and make data filtering easier?” In this in-depth guide, I’ll walk you through exactly how to do that—from understanding the architecture to writing clean, maintainable XML and Python code.

What Are Custom Filters in Odoo?

Custom filters allow users to quickly narrow down the records displayed in a view (Kanban, Tree, or Form) based on specific criteria. These filters appear in the search view as buttons, drop-downs, or input fields.

In a Kanban view, these filters help users segment data visually—for example:

  • “Tasks due this week”
  • “High-priority tickets”
  • “Opportunities in the final stage”

By default, Odoo provides basic filters (like My Records, Archived, etc.), but you can enhance the UX by adding custom domain-based filters for your use case.

Step-by-Step: Adding a Custom Filter in Odoo

Before we start, make sure:

  • You have access to the Odoo backend or are developing in Odoo.sh or an on-prem environment
  • You’re familiar with Odoo XML views and model inheritance
  • You have developer mode enabled in Odoo

Follow the steps below carefully to add a custom filter in Odoo:

Step 1: Inherit the Search View in Custom Module

A linked search view accompanies every view in Odoo. This is where filters are defined. You’ll need to locate and inherit this search view.

    <record id="view_task_search_custom_filter" model="ir.ui.view">
        <field name="name">project.task.search.inherit.custom</field>
        <field name="model">project.task</field>
        <field name="inherit_id" ref="project.view_task_search_form"/>
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='my_tasks']" position="after">
                <filter string="Due This Week" name="due_this_week"
                    domain="[('stage_id.name', '=', 'In Progress'),
                    ('date_deadline', '<=', (context_today() + relativedelta(days=7)).strftime('%Y-%m-%d'))]"
                    help="Tasks that are in progress and due in the next 7 days"/>
            </xpath>
        </field>
    </record>

Breakdown:

  • We inherit the existing search view for project.task
  • Add a new filter with a domain:
    • Checks the stage name
    • Uses date_deadline field and Python expression for dynamic date filtering
  • context_today() is used to fetch today’s date

Step 2: Verify and Test

  1. Upgrade Your Custom Module
    • Via Command Line: odoo -u your_module_name
    • Or via Apps > Updates Apps List > Upgrade
  2. Navigate to Project > Tasks > Search View
  3. Open the filters and check if your new filter appears.
  4. Apply it and confirm that only relevant records show up.

Bonus: How to Add a Group Filter in Odoo

You can go beyond basic filters by using:

  • Group By: Helps users group records visually (e.g., by Priority or Assigned User)

Here’s how to add a Group By in the same search view:

<group expand="0" string="Group By">
    <filter string="Assigned To" name="user_id" context="{'group_by': 'user_id'}"/>
</group>

Best Practices for Custom Filters in Odoo

As an Odoo consultant, here are a few tips I always share:

  1. Don’t overload the search view – Stick to 3–5 relevant filters.
  2. Name your filters clearly – Use simple, action-oriented labels like “Due Today” or “Unassigned Tasks”.
  3. Test thoroughly – Filters should work consistently across views (Kanban, Tree, etc.).
  4. Document custom domains – For teams or future developers.

Can You Do This in Odoo Studio?

Yes, if you’re using Odoo Studio (Enterprise), you can add custom filters visually:

  • Open the view in Studio
  • Click the magnifying glass to edit filters
  • Add a new domain-based condition

However, for dynamic date filters or logic based on stage names, you may still need a developer’s help.

Related Posts:

>> How to Configure Odoo with Nginx as a Reverse Proxy

>> What is Odoo Runbot and How to Access It?

>> How to Add a Button to the Action Menu in Odoo 17

>> Understanding OWL JS Lifecycle Hooks in Odoo 17

Final Words: Add a Custom Filter in Odoo

Add a Custom filter in Odoo views is more than a convenience—it’s a powerful way to help users focus on what matters most. Whether you’re handling tasks, sales, or support tickets, the right filters can improve productivity, reduce clutter, and enhance decision-making.

By following this guide, you’ve learned how to:

  • Inherit and modify Odoo’s search views
  • Add dynamic or static filters to view
  • Optimize the user interface for your business needs

Odoo’s strength lies in its flexibility. So, take advantage of that—build what your users need.

Need Help?

If you’re a business owner or team lead looking to customize your Odoo views but don’t have an in-house developer, feel free to reach out to an experienced Odoo consultant. Customization doesn’t have to be complicated, and the results are always worth it.

Our Odoo Apps Store Account: Visit Here

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.