+1 vote
17 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.2k points) | 17 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.6k points)
192 questions
163 answers
32 comments
38,833 users