+1 vote
105 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) | 105 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
178 answers
34 comments
112,141 users