Skip to Content
Menu
This question has been flagged
2 Replies
2597 Views

Is there a way when you make a call to the xml rpc webservice to have the obtained records sorted in ascending/descending order?



Avatar
Discard
Best Answer

Use the order argument:


order="date"   (if not specified, defaults to be ASC) 
order="name DESC"

Model.search (domain[, offset=0][, limit=None][, order=None][, count=False])[source]

Searches for records based on the domain search domain.

Parameters

  • domain – A search domain. Use an empty list to match all records.

  • offset (int) – number of results to ignore (default: none)

  • limit (int) – maximum number of records to return (default: all)

  • order (str) – sort string

  • count (bool) – if True, only counts and returns the number of matching records (default: False)

Returns: at most limit records matching the search criteria

Raises: AccessError – if user is not allowed to access requested information


From https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.models.Model.search

Avatar
Discard
Best Answer

Hello Olivier Biltris,

Please find code in comment.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

You can use bellow example

In the search record for a partner, you can add orders like order id desc or asc.

models.execute_kw(db, uid, password,
'res.partner', 'search_read',
[[['is_company', '=', True], ['customer', '=', True]]],
{'fields': ['name', 'country_id', 'comment'], 'order': 'id desc'})