I try to use search()
to fetch data from a table in a http controller.
x = obj.search(cr, uid, criteria, offset=0,limit=36,order=sortBy)
It returns an array containing the ids of the top 36 items ordered by sortBy
but always in increasing order. But how to make it using decreasing order?
Search
Takes a search domain, returns a recordset of matching records. Can return a subset of matching records (offset and limit parameters) and be ordered (order parameter):
Syntax:
search(args[, offset=0][, limit=None][, order=None][, count=False])
Parameters:
Returns: Returns records matching the search criteria up to limit.
Raise AccessError: if user tries to bypass access rules for read on the requested object.
You just need to search in following manner with descending order.
sortBy = "field_name desc"
x = obj.search(cr, uid, criteria, offset=0,limit=36,order=sortBy)
###Or you can define directly
x = obj.search(cr, uid, criteria, offset=0,limit=36,order='field_name desc')