Reputation: 3640
Using the ripcord XML-RPC client and making a call like the following, how can I tell it by which field(s) to sort the records?
$models = ripcord::client($cfg['url'] . '/xmlrpc/2/object');
$srch = $models->execute_kw($cfg['db'], $cfg['uid'], $cfg['pw'], 'account.move.line', 'search_read', array(array(array('account_id', '=', 174), array('date', '>=', '2016-01-01'))));
Using Odoo 9 Community Edition.
Upvotes: 3
Views: 5397
Reputation: 1318
For those arriving here from search engines, the same syntax in python will look like:
pickings = models.execute_kw(db, uid, pwd, 'stock.picking', 'search_read',
[[['state', '=', 'done'], ['date_done', '>', '2019-01-01']]],
{'fields':['name'], 'offset': 0, 'limit': 5, 'order': 'date_done desc'})
Upvotes: 1
Reputation: 2633
The signature of search_read
is:
def search_read(self, cr, uid, domain=None, fields=None, offset=0, limit=None, order=None, context=None):
I am not very familiar with PHP, but something like this should work:
$models = ripcord::client($cfg['url'] . '/xmlrpc/2/object');
$srch = $models->execute_kw(
$cfg['db'],
$cfg['uid'],
$cfg['pw'],
'account.move.line',
'search_read',
array(
array(
array('account_id', '=', 174),
array('date', '>=', '2016-01-01')
),
NULL,
NULL,
NULL,
'date desc, id',
)
);
We pass NULL
for fields
, offset
and limit
to use the default value and order
is a comma-separated list of fields to sort on. In the above example it will return the move lines sorted by date
in descending order and then by id
(if some move lines have the same date) in ascending order.
Upvotes: 6