python-3.xodooodoo-13

How to add "and" search operators to odoo XML-RPC api calls?


I have a search statement that is the following

models.execute_kw(db, uid, password,'stock.move', 'search_read',                                                                 [[['origin','=','INVOICE ## 44'],
['picking_type_id', '=', 2],
['product_id', '=', 123],
['state', '=', 'cancel']]],
) 

I would like to be able to search for records that are cancelled AND assigned. I have attempted the following.

models.execute_kw(db, uid, password,'stock.move', 'search_read',                                                                 [[['origin','=','INVOICE ## 44'],
    ['picking_type_id', '=', 2],
    ['product_id', '=', 123],
    ['|', ['state', '=', "cancel"], ['state', '=', "assigned"]]]
    ) 

However, this returns an error of the list not being a proper operator. I have checked the documentation https://www.odoo.com/documentation/13.0/developer/reference/addons/orm.html and while they have examples, they do not have a clear explanation of how to implement for multiple of the same states or other attributes.


Solution

  • For anyone else having similar issues, Kenly above was able to solve it, was a syntax issue. I was not able to find a clear example of this anywhere online, so posting here in case anyone finds a similar issue.

    models.execute_kw(db, uid, password,
    'stock.picking', 'search_read',
    [['|', ['state', '=', "cancel"], ['state', '=', "assigned"]]])