Reputation: 9220
I'm trying to filter by a specific product code using odoo's PHP api. If I filter by qty_available > 0
it works fine:
$records = $models->execute_kw($db, $uid, $pass, 'product.product', 'search_read', array(
array(
array('qty_available', '>', 0),
),
), array(
'fields' => array('code', 'display_name', 'qty_available')
));
... but when I filter by code, it returns all results, essentially ignoring any filters:
$records = $models->execute_kw($db, $uid, $pass, 'product.product', 'search_read', array(
array(
array('code', '=', 'T-0001'),
),
), array(
'fields' => array('code', 'display_name', 'qty_available')
));
Does anyone know why this may be happening please? It also works fine using an integer ID, just not the string code. Thanks!
Upvotes: 0
Views: 925
Reputation: 9220
Thanks to Prakash Sharma for his help, but it turns out out that the actual way to get it to work was to use product.product
's field default_code
rather than code
, which fortunately is searchable. This may be different depending on others' setups, but I wasn't willing to go in and change the database and I think the internal reference should be kept pure as it was designed.
Upvotes: 1
Reputation: 2594
In the model product.product
code
field is the functional field/compute field .
These type of field are Not Searchable by default.
But you can mark the store=True , and search it.
NOTE:There are pros as well as con's of marking the store=True
Upvotes: 1