+1 vote
109 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) | 109 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)
205 questions
178 answers
34 comments
117,298 users