Odoo Help

0

for order in self.browse(cr, uid, ids, context=context), what self.browse does?

By
E.M.
on 2/8/16, 7:22 PM 1,857 views

I am extending sale.order. I have noticed that in order to gather the object in the old api you can do:

for order in self.browse(cr, uid, ids, context=context):

I would like to know what self.browse does, and why do I have to iterate over it.

1
Axel Mendoza
On 2/8/16, 9:12 PM

I think that you will find extremelly helpful the entire read of this page

https://www.odoo.com/documentation/8.0/reference/orm.html

It will clarify you a lot of stuff related with the development of Odoo models, I was using the old api for a long time and to jump into the new api I just read very carefully that page. At the end there is the "Porting from the old API to the new API" topic that also bring some light to the use of the two api versions

I have read it throughly, it clarified. Still not mastering when old and new api are mixed.

E.M.
on 2/9/16, 10:55 AM

The old api and the new api differs in the use of the arguments cr. uid, ids, context, in the return of the methods. When the new api manage recordsets, in the old api you manage everything. Think the new api as using Active Records while the old api you call the methods to get the values even when the browse_record class acts a little as an Active Record in the old api. The browse in the new api and the old api only differs in that for the new api the arguments cr, uid and context are not needed since they are retrieved from the Environment attached to self

Axel Mendoza
on 2/9/16, 4:38 PM
0
Samantha Cruz
On 2/8/16, 7:37 PM


self.browse

 as a sql, it select records by Id. Note if you pass a browse an integer you get a single browse record, if you pass a list of ids you get a list of browse records.

Note that browse() doesn't actually do the query; it just creates the objects. Only when you access an attribute of one of the objects does it actually query the database.

André Pereira
on 2/9/16, 5:31 AM

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.

Register

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

1 follower(s)

Stats

Asked: 2/8/16, 7:22 PM
Seen: 1857 times
Last updated: 8/13/17, 10:11 AM