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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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.
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.
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
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.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Feb 16
|
3368 | ||
|
0
Sep 24
|
3 | ||
|
0
Sep 24
|
348 | ||
|
1
Jun 24
|
664 | ||
|
1
Mar 24
|
914 |