Skip to Content
Menu

Pattern Search

by
Odoo
v 18.0 Third Party 12
Download for v 18.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 48
Technical Name pattern_search
LicenseLGPL-3
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Lines of code 48
Technical Name pattern_search
LicenseLGPL-3

Pattern Search

Autocomplete search in the form view

autocomplete_form

Autocomplete search in the search view

autocomplete_search

Pattern search in the search view

pattern_search

📢 Available for Hire!

Looking for a skilled and reliable Odoo Developer to bring your business ideas to life? or to fix things? or to analyze unwanted results? or to do whatever in odoo

Let’s build something great together! I specialize in custom module development, ERP implementation, and performance tuning tailored to your needs.


📬 Hire Me wa.me/923482852693 /rajeelzahid

Overview

This module enhances the search behavior of many2x fields in Odoo by introducing a pattern-based search mechanism. Instead of relying solely on the default ilike search, it allows users to search by meaningful fragments of the name. This is particularly helpful in cases where records (e.g. employees) share common prefixes like "Muhammad", enabling quicker and more intuitive access to relevant records.

Key Features

  • Improves usability of many2x fields with large datasets
  • Supports pattern-based searching (e.g., "muhra" matches "Muhammad Rajeel")
  • Context-aware as only applies when explicitly enabled
  • Lightweight and non-intrusive to existing logic
  • Compatible with all standard and custom models

How to Use

  1. Autocomplete search in the form view

    autocomplete_form

    In your form view XML, add context="{'pattern_search': True}" to the many2x field definition.

    Example:

    <form>
        <field name="employee_id" context="{'pattern_search': True}" />
    </form>

    Once enabled, the field will support pattern matching: typing muhra will match "Muhammad Rajeel", and rjl will also return similar results even if the full name doesn't begin with it.

  2. Autocomplete search in the search view

    autocomplete_search

    In your search view XML, add context="{'pattern_search': True}" to the field definition.

    Example:

    <search>
        <field name="department_id" context="{'pattern_search': True}" />
    </search>

    Once enabled, the field will support pattern matching: typing proser will match "Professional Services",

  3. Pattern search in the search view

    pattern_search

    Same as #2

    Example:

    <search>
        <field name="name" context="{'pattern_search': True}" />
    </search>

    Once enabled, the field will support pattern matching: searching muhra will match "Muhammad Rajeel",

    Use with filter_domain:

    If using filter_domain in search field, use raw_value instead of self in domain

    Example:

    <search>
        <field name="name" string="Employee" filter_domain="['|', ('work_email', 'ilike', self), ('name', 'ilike', raw_value)]" context="{'pattern_search': True}"/>
    </search>

    work_email will be searched without pattern but name will be searched with pattern

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.