def search_read(cls, domain, offset=0, limit=None, order=None,
fields_names=None):
'''
Call search and read functions at once.
Useful for the client to reduce the number of calls.
'''
records = cls.search(domain, offset=offset, limit=limit, order=order)
if not fields_names:
fields_names = cls._fields.keys()
if 'id' not in fields_names:
fields_names.append('id')
rows = cls.read(map(int, records), fields_names)
index = {r.id: i for i, r in enumerate(records)}
rows.sort(key=lambda r: index[r['id']])
return rows
评论列表
文章目录