Use the "id" field in a view

Asked by Francois Degrave


I would like to use the "id" field for domain purposes in a view. In __view_look_dom_arch of file I read this (l. 1666):

 # sometime, the view may contain the (invisible) field 'id' needed for a domain (when 2 objects have cross references)

Unfortunately, if I use this id field in a view, it crashes because "id" does not appear in _columns ("key error").

Question information

English Edit question
Odoo Server (MOVED TO GITHUB) Edit question
No assignee Edit question
Solved by:
Francois Degrave
Last query:
Last reply:
Revision history for this message
Naresh(OpenERP) (nch-openerp) said :

Hello Francois,

may be you need to see this first:

Hope this helps !


Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :

Hi Francois,

what worked for me is to explicitely declare the field in the model columns. It does not affect the database structure, but it makes the field available for purposes such as yours.

The same thing happens at a number of occasions in the official addons. Here is an example from the crm_claim module:

    'id': fields.integer('ID', readonly=True),


Revision history for this message
Francois Degrave (fde-be) said :

Thanks Stefan!

On my side what I did is monkey patching the "read" method to get rid of "id" in the fields argument, in order to avoid this key error. But thanks for the tip anyway!