How it works...

The implementation of the filter() method of recordsets creates an empty recordset in which it adds all the records for which the predicate function evaluates to True. The new recordset is finally returned. The order of records in the original recordset is preserved.

The preceding recipe used a named internal function. For such simple predicates, you will often find an anonymous lambda function used:

@api.model 
def partners_with_email(self, partners): 
    return partners.filter(lambda p: p.email) 

Actually, to filter a recordset based on the fact that the value of a field is truthy in the Python sense (non-empty strings, non-zero numbers, non-empty containers, and so on), you can pass the field name to filter like this partners.filter('email').