December 2018
Beginner to intermediate
404 pages
10h 14m
English
The special case of a recordset with only one record is called a singleton. Singletons are still a recordset and can be used wherever a recordset is expected.
But unlike multi-element recordsets, singletons can access their fields using the dot-notation, like this:
>>> print(self.name) OdooBot
In the next example, we can see the same self singleton recordset also behaves as a recordset, and we can iterate it. It has only one record, so only one name is printed out:
>>> for rec in self:
print(rec.name)
OdooBot
Trying to access field values on recordsets with more than one record will result in an error, so this can be an issue in the cases where we are not sure if we are working with a singleton recordset. For methods ...
Read now
Unlock full access