O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Search views

When opening your list view, you'll notice the search field to the upper right. If you type something there, you get suggestions about what to search for and there is also a set of predefined filters to choose from. This recipe will walk you through how to define those suggestions and options.

How to do it...

  1. Define your search view:
    <record id="search_all_customers" model="ir.ui.view">
        <field name="model">res.partner</field>
        <field name="arch" type="xml">
            <search>
                <field name="name" />
                <field name="category_id"
                       filter_domain="[('category_id', 'child_of', self)]" />
                <field name="bank_ids" widget="many2one" />
                <filter name="suppliers"
                        string="Suppliers"
                        domain="[('supplier', '=', True)]" />
            </search>
        </field>
    </record>
  2. Tell your action ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required