'Apply function ``func`` on all records in ``self``, and return the
result as a list or a recordset (if ``func`` returns recordsets).'

def _mapped_func(self, func):

    if self:
        vals = [func(rec) for rec in self]
        if isinstance(vals[0], BaseModel):
            return vals[0].union(*vals)
        return vals
    else:
        vals = func(self)
        return (vals if isinstance(vals, BaseModel) else [])
