If we obtain a recordset of model instances (through search() or browse()), what kinds of operations are available? Can recordsets be added (set + set)? Can they be appended to (setA.append(record))?
Does the recordset behave like some well known Pythonic structure (like list)? If not, is there some kind of reference that lists what operations are and aren't available?
Other recordset operations:
1. sorted(): To sort a recordset
# sort records by name
recset.sorted(key=lambda r: r.name)
2. filtered(): To filter a recordset:
# only keep records whose company is the current user's
records.filtered(lambda r: r.company_id == user.company_id)
# only keep records whose partner is a company
3. mapped(): To map a recordset by applying the provided function to each record in the recordset and returns a recordset if the results are recordsets.
recordset.mapped(lambda record: record.amount + record.tax_amount)
# returns a list of name
# returns a recordset of partners
About This Community
|Asked: 9/3/14, 4:31 AM|
|Seen: 2502 times|
|Last updated: 10/30/15, 3:35 AM|