Search code examples
odooodoo-11

How to get a sorted list of filtered values of records in Odoo using filtered() function


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?


Solution

  • Try this one

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