Odoo Help

Welcome!

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.

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,007 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

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

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

1 follower(s)

Stats

Asked: 2/8/16, 7:22 PM
Seen: 1007 times
Last updated: 2/12/16, 12:38 PM