Odoo Help


This community 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.


Does the ORM always return and receive lists (of ids)?

René Schuster
on 5/21/14, 4:46 AM 11,167 views

The Documentation states that the various methods of the class openerp.osv.orm.BaseModel like browse, search, write, etc. can receive and return a single id/record.

Example: return value for browse method:

Return type: object or list of objects requested

Or select argument for browse method:

select -- id or list of ids.

Or return value for search method:

Returns: id or list of ids of records matching the criteria

I often have the feeling that this is not true and all methods allways expect and return lists.

Is my feeling wrong?


EDIT (in lack of comment functionality):

Thx, Mr. Reis. You are quite right! But is it also true for search?


Search always returns a list. The documentation is wrong. (Although the technical memento states it correctly).


Daniel Reis

--Daniel Reis--
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt

Daniel Reis
On 5/21/14, 9:41 AM

It's actually True:

If you do `object.browse(cr, uid, id)`you get one Browse record use use dot-notations directlty on it.

If you do `object.browse(cr, uid, [ids])` you get a *list* of Browse and you should iterate on it to deal with each Browse record.


Martin Trigaux (mat)

--Martin Trigaux (mat)--
| 6 4 7
Grand Rosiere, Belgium
--Martin Trigaux (mat)--

Community manager: help with the code and translations contributions from the community on GitHub and Transifex.

Developed the gamification module and is also now responsible of the documentation and Point of Sale.

Martin Trigaux (mat)
On 5/21/14, 5:26 AM

It's a good practice to always

  • send or return a list of ids
self.write(cr, uid, [lead.id], vals, context=context)
  • expect both
if isinstance(ids, (int, long)):
    ids = [ids]


copy is one of the only method of the orm that expects an int instead of a list.


Sudhir Arya (SA)

--Sudhir Arya (SA)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow




Sudhir Arya (SA)
On 5/21/14, 2:20 PM

Yes, it is right that most of the ORM methods accepts list of IDs and some of them returns list of IDs or single ID.

Search methods returns list of IDs, write, unlink returns True and create returns new ID.

You can see all the methods here: http://bazaar.launchpad.net/~openerp/openobject-server/7.0/view/head:/openerp/osv/orm.py

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

4 follower(s)


Asked: 5/21/14, 4:46 AM
Seen: 11167 times
Last updated: 6/7/15, 2:35 AM