diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-07-07 14:13:07 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-07-07 14:13:07 +0200 |
| commit | 5b285707693dd1064dde40778259cc0525eca15f (patch) | |
| tree | c2f3c22fa3494f7f6f929a57ce530ff01127e4ae /doc/reference | |
| parent | 19276549774023128da681821d6cf088ed34524b (diff) | |
| parent | aef774884597342e4d716d606d2ca3b2d239fb4e (diff) | |
[MERGE] forward port branch 10.0 up to aef77488459
Diffstat (limited to 'doc/reference')
| -rw-r--r-- | doc/reference/orm.rst | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/doc/reference/orm.rst b/doc/reference/orm.rst index 876d74f65cc..00b284f9cb2 100644 --- a/doc/reference/orm.rst +++ b/doc/reference/orm.rst @@ -45,14 +45,20 @@ Field access ------------ Recordsets provide an "Active Record" interface: model fields can be read and -written directly from the record, but only on singletons (single-record -recordsets). Setting a field's value triggers an update to the database:: +written directly from the record as attributes, but only on singletons +(single-record recordsets). +Field values can also be accessed like dict items, which is more elegant and +safer than ``getattr()`` for dynamic field names. +Setting a field's value triggers an update to the database:: >>> record.name Example Name >>> record.company_id.name Company Name >>> record.name = "Bob" + >>> field = "name" + >>> record[field] + Bob Trying to read or write a field on multiple records will raise an error. |
