Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
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
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar