Odoo Help


How to get the Keys of a returned browse_record object?

Peter Nietz
on 9/5/14, 8:49 AM 2,354 views

Hi Guys ...

from what I understood should self.pool['whatever'].browse(cr, uid, SINGLEID)  return a dictonary object.

current_obj = self.pool['mymod.myclass'].browse(cr, uid, oid)


length = current_obj.len()

doesn't work and throws an error.

I want now to get the key and value pair of the _columns dictonary and tried:

for (key, value) in current_app_obj.items(): ... 


for key in current_app_obj.keys(): ... 
     value = getattr(current_app_obj, key)

and also

keys = current_app_obj.keys()
for key in keys:
       value = getattr(current_app_obj, key)

>>>  [...] raise except_osv('Object Error', 'Object %s doesn\'t exist' % str(obj))
except_osv: ('Object Error', "Object object.name doesn't exist")

Where is my error? Is the return value of browse really a dictonary? Why can't I use the standart methods?

Which libraries do I have to include?

Any hint is appreciated.

Sudhir Arya (SA)
On 9/5/14, 1:50 PM

Hello Peter,

I think you didn't understand standard methods, their use and their return type.

First thing is you should use `self.pool.get('your.object.name')`.

Browse method always returns browse object not dictionary.

If you pass single ID in browse method, it will return single browse record. Same way if you pass list of IDs, it will return list of browse records.

You can get values of any field from browse record using . (dot) operator.

If you want a dictionary, you should use read method which returns dictionary with fields name as a key and fields value in value of the dictionary.

You can refer following link for standard methods.

ORM Methods

Hope this will help you.

hi, Sudhir... current_obj = self.pool['mymod.myclass'].browse(cr, uid, oid) works just the same or even better as mentioned here: http://hypered.io/blog/2013-12-30-self-pool-get/ but your hint using read instead of browse made my day! THX... Thumb up!

Peter Nietz
on 9/9/14, 9:16 AM

Better you use self.pool.get() that is the better approach.

Sudhir Arya (SA)
on 9/9/14, 12:54 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 9/5/14, 8:49 AM
Seen: 2354 times
Last updated: 3/16/15, 8:10 AM