Using the search_read method

While the preceding code only returns the IDs of the records, the new Odoo API allows you to both search and read the actual fields from the model with one single API call. Here, we return some fields from the sales order header:

models.execute_kw(db, uid, password, 
    'sale.order', 'search_read', 
    [[['x_rush, '=', True], ['state', '=', 'done']]], 
    {'fields': ['name', 'country_id', 'comment'], 'limit': 5}) 

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.