+1 vote
219 views

How can I filter and return a sorted list from a set of records choosing which field to sort from using filter() and sort() function in Odoo?

in Back-end by (10.5k points) | 219 views

1 Answer

0 votes

Hi,

You can try like this,

records.filtered(lambda r: r.company_id == user.company_id).sorted(key=lambda r: r.name)

For more: https://docs.python.org/3/library/functions.html#sorted

Thanks

by (8.8k points)
202 questions
179 answers
35 comments
167,080 users