python - In Odoo 8 ORM api , how to get results in reverse order using search()? -
i try use search() fetch data table in http controller.
x = obj.search(cr, uid, criteria, offset=0,limit=36,order=sortby)
it returns array containing ids of top 36 items ordered sortby
in increasing order. how make using decreasing order?
search
takes search domain, returns recordset of matching records. can return subset of matching records (offset , limit parameters) , ordered (order parameter):
syntax:
search(args[, offset=0][, limit=none][, order=none][, count=false])
parameters:
- args -- search domain. use empty list match records.
- offset (int) -- number of results ignore (default: none)
- limit (int) -- maximum number of records return (default: all)
- order (str) -- sort string
- count (bool) -- if true, counts , returns number of matching records (default: false)
returns: returns records matching search criteria limit.
raise accesserror: if user tries bypass access rules read on requested object.
you need search in following manner descending order.
sortby = "field_name desc" x = obj.search(cr, uid, criteria, offset=0,limit=36,order=sortby) ###or can define directly x = obj.search(cr, uid, criteria, offset=0,limit=36,order='field_name desc')
Comments
Post a Comment