Creating the filter

The filter is specified by one line of XML code:

<filter name="rush" string="Rush Only"  domain="[('rush','=',True)]"/> 

In this code, we specify the name of our filter and the string we wish to display in the search view. The filter is applied with the domain parameter. We specify the field from our sales order model and that it must equal true in order for this filter to be valid.

The technical name for this syntax in Python is a tuple. It is possible to include multiple filters in the domain. For example, we can also specify that we only want sales orders that are confirmed by specifying an additional condition in our filter:

<filter name="rush" string="Rush Only"  domain="[('rush','=',True),('state','=','progress')]"/> ...

Get Working with Odoo 11 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.