Hello,
I am under Odoo 17 and using its external API .
I successfully fetch the products from database with a filter on product category.
However, I am interested in filtering them by using several criteria with "AND" operator.
When I simply add multiple criteria, it implicitly works as an OR operator.
In my "search_read" request, my filter look like this (json format for our convenience)
[[["categ_id","in",[37]],["quantity_svl",">","0"],["lst_price","Meaning : Find product that are in category 37 (OR) with quantity_svl greater than 0, (OR) lst_price lower or equal to 2
After some research, i have found and tested an old post (xml-rpc-api-object-search-mixing-and-and-or-58468)
Witch transform my filter to this
[["&","&",["categ_id","in",[37]],["quantity_svl",">","0"],["lst_price","and should mean : Find product that are in category 37 AND with quantity_svl greater than 0, AND lst_price lower or equal to 2
There is no error but the results are the same. Maybe it is obsolete?
My question is : do someone knows the correct way to use AND operator for filtering products in "search_read" requests ?
Thanks for your help !
To summary, my request look like this
$filters = [
'search' => [[
'&',
'&',
['categ_id', 'in', [37,15, etc...]],
['quantity_svl', ' ['lst_price', ' ]],
'display' => [
'offset' => 0,
'limit' => 12,
'fields' => ['name', 'image_512', 'lst_price', 'image_512', 'categ_id', 'quantity_svl', 'default_code', 'active', 'barcode'],
]
];
$models->execute_kw(ODOO_DB, $uid, ODOO_PASSWORD, 'product.product', 'search_read', $filters['search'], $filters['display']);