From 4d4ff7c5e7982285f2137e6f1a1ca8d2bc569d27 Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Wed, 28 Jun 2017 17:38:32 +0200 Subject: [IMP] doc: mixing attrs and states is iffy --- doc/reference/views.rst | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'doc/reference') diff --git a/doc/reference/views.rst b/doc/reference/views.rst index 4622716ff7e..054cfbf0be8 100644 --- a/doc/reference/views.rst +++ b/doc/reference/views.rst @@ -234,6 +234,11 @@ Possible children elements of the list view are: Makes the button ``invisible`` if the record is *not* in one of the listed states + + .. danger:: + + Using ``states`` in combination with ``attrs`` may lead to + unexpected results as domains are combined with a logical AND. ``context`` merged into the view's context when performing the button's Odoo call ``confirm`` -- cgit v1.2.3 From 464fe4a185316cf9af9ae15385bd55662534109b Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 6 Jul 2017 15:58:01 +0200 Subject: [FIX] doc: clarify: `record[field]` is valid/recommended --- doc/reference/orm.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'doc/reference') 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. -- cgit v1.2.3