Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
Hi, It is a environment object that Encapsulates cr, uid, context:
recs.env encapsulates cr, uid, context:
recs.env.cr # shortcut: recs._cr
recs.env.uid # shortcut: recs._uid
recs.env.context # shortcut: recs._context
recs.env also provides helpers:
recs.env.user # uid as a record
recs.env.ref('base.group_user') # resolve xml id
recs.env['res.partner'] # access to new-API model
Switching environments:
rebrowse recs with different parameters
env2 = recs.env(cr2, uid2, context2)
recs2 = recs.with_env(env2)
special case: change/extend the context
recs2 = recs.with_context(context2)
recs2 = recs.with_context(lang='fr') # kwargs extend current context
special case: change the uid
recs2 = recs.sudo(user)
recs2 = recs.sudo() # uid = SUPERUSER_ID
Hello Novizco,
It is a wrapper class that wraps
cr - current database cursor
uid - current user id
context - context dictionary
also it manages the pool of objects i.e. registry the models
Earlier these attributes were having independent existance, but from v8 these attributes gets wrapped under "env". You can access them as follows :
self.env.cr
self.env.uid
self.env.context
which gives more object oriented approach.
Regards
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire