Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Defining filters on record lists: Domain


We've already seen the first example of a domain in the first action, which was [('customer', '=', True)]. It is a very common use case when you need to display a subset of all available records from an action, or to allow only a subset of possible records to be the target of a many2one relation. The way to describe these filters in Odoo is called a domain. This recipe illustrates how to use such a domain to display a selection of partners.

How to do it...

To display a subset of partners from your action, you need to perform the following steps:

  1. Add an action for non-French speaking customers:

    <record id="action_my_customers" model="ir.actions.act_window">
        <field name="name">
            All customers who don't speak French
        </field>
        <field name="res_model">res.partner</field>
        <field name="domain">
            [('customer', '=', True), ('user_id', '=', uid), ('lang', '!=', 'fr_FR')]
        </field>
    </record...