Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
env(Environment) in new API is to provide an encapsulation around cursor, user_id, model, and context, Recordset and caches.
It evades the use of infamous function signature def afun(self, cr, uid, ids, context=None): and in new API its def afun(self):
And if you want to call ORM method directly from an object you can use self.env['obj'].method instead of self.method
For more about env:- Link
Hope this helps.
self.env['model.name'] is used instead of self.pool.get('model.name') in the old api, to access the recordset of a particular model. In the old api, with search and browse you had pass cr, uid, context seperately, whereas with self.env it is implicit.
An environment wraps data for ORM records:
'cr', the current database cursor.
'uid', the current user id.
'context', the current context dictionary.
You may check this link:
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 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
|Asked: 10/16/15, 12:09 AM|
|Seen: 5544 times|
|Last updated: 12/1/15, 4:43 AM|