Odoo Environment | Odoo Self | self.env in Odoo || Odoo Environment Variables

  Рет қаралды 11,646

Odoo Mates

Odoo Mates

Күн бұрын

What is self in odoo. What is a record set in odoo. How to traverse recordset in Odoo. Odoo environment variables. How to initialize odoo environment. Environmental variables in Odoo. How to alter odoo environment. What is odoo self.env . User object in odoo environment. Context in Odoo. Get user language in odoo python. Get current user id in odoo python. Get current company in odoo python. Odoo database cursor.
Need the playground module ? apps.odoo.com/...
Feel free to buy from above link which will be a great support for us !!! If you cant buy, no issues, ping us in email: odoomates@gmail.com
Available variables
- self: Current Object
- self.env: Odoo Environment on which the action is triggered
- self.env.user: Return the current user (as an instance)
- self.env.is_system: Return whether the current user has group "Settings", or is in superuser mode.
- self.env.is_admin: Return whether the current user has group "Access Rights", or is in superuser mode.
- self.env.is_superuser: Return whether the environment is in superuser mode.
- self.env.company: Return the current company (as an instance)
- self.env.companies: Return a recordset of the enabled companies by the user
- self.env.lang: Return the current language code
- self.env.cr: Cursor
- self.env.context: Context
The Environment stores various contextual data used by the ORM: the database cursor (for database queries), the current user (for access rights checking) and the current context (storing arbitrary metadata). The environment also stores caches.
All recordsets have an environment, which is immutable, can be accessed using env and gives access to:
the current user (user)
the cursor (cr)
the superuser flag (su)
or the context (context)
records.env
Environment object
records.env.user
res.user(3)
records.env.cr
Cursor object ...)
When creating a recordset from an other recordset, the environment is inherited. The environment can be used to get an empty recordset in an other model, and query that model:
self.env['res.partner']
res.partner()
self.env['res.partner'].search([['is_company', '=', True], ['customer', '=', True]])
res.partner(7, 18, 12, 14, 17, 19, 8, 31, 26, 16, 13, 20, 30, 22, 29, 15, 23, 28, 74)
Environment.ref(xml_id, raise_if_not_found=True)[source]
Return the record corresponding to the given xml_id.
Environment.lang
Return the current language code.
Return type
str
Environment.user
Return the current user (as an instance).
Returns
current user - sudoed
Return type
res_users
Environment.company
Return the current company (as an instance).
If not specified in the context (allowed_company_ids), fallback on current user main company.
Raises
AccessError - invalid or unauthorized allowed_company_ids context key content.
Returns
current company (default=`self.user.company_id`), with the current environment
Return type
res.company
Warning
No sanity checks applied in sudo mode ! When in sudo mode, a user can access any company, even if not in his allowed companies.
This allows to trigger inter-company modifications, even if the current user doesn’t have access to the targeted company.
Environment.companies
Return a recordset of the enabled companies by the user.
If not specified in the context(allowed_company_ids), fallback on current user companies.
Raises
AccessError - invalid or unauthorized allowed_company_ids context key content.
Returns
current companies (default=`self.user.company_ids`), with the current environment
Return type
res.company
Warning
No sanity checks applied in sudo mode ! When in sudo mode, a user can access any company, even if not in his allowed companies.
This allows to trigger inter-company modifications, even if the current user doesn’t have access to the targeted company.
Odoo 15 Playlist: • How To Configure Odoo1...
Website: www.odoomates....
Instgram: / odoomates
Github: github.com/odo...
Email : odoomates@gmail.com
Facebook: / odoomate
Twitter: / odoomates
Support Us in Ko Fi : ko-fi.com/odoo...

Пікірлер: 44
@futhedude4848
@futhedude4848 2 жыл бұрын
For this explaination video, i suggest you to use debugger of pycharm, it will easily show full of env variable.
@OdooMates
@OdooMates 2 жыл бұрын
thanks brother for suggestion
@dipakmali6676
@dipakmali6676 Жыл бұрын
Very nice teaching great explanations about environment
@OdooMates
@OdooMates Жыл бұрын
So nice of you
@adrianseguratrista5666
@adrianseguratrista5666 2 жыл бұрын
Greetings from Cuba. Thank you very much.
@OdooMates
@OdooMates 2 жыл бұрын
Glad it.helped ❤️❤️❤️
@aunnfriends
@aunnfriends 2 жыл бұрын
A very beautiful playground!
@OdooMates
@OdooMates 2 жыл бұрын
glad to hear it
@nadeemkazi2092
@nadeemkazi2092 2 жыл бұрын
Thanks odoo mates..its useful info.
@OdooMates
@OdooMates 2 жыл бұрын
Welcome brother ❤️❤️
@elmehdielouali5850
@elmehdielouali5850 2 жыл бұрын
good job, thanks for sahring the module, I am grateful
@OdooMates
@OdooMates 2 жыл бұрын
Glad to help
@mohamedboudekak8574
@mohamedboudekak8574 2 жыл бұрын
Hello, Greate video as always, is it possible to share the odoo playground model. Thanks
@OdooMates
@OdooMates 2 жыл бұрын
@hectorherrera4193
@hectorherrera4193 2 жыл бұрын
Great explanation!. Now finally some concepts are matching. Thanks for sharing. How can I get the code for an Odoo Playground?
@OdooMates
@OdooMates 2 жыл бұрын
Can you drop an email to odoomates@gmail.com, so we can share the code
@abdussattarbhuiyan4566
@abdussattarbhuiyan4566 2 жыл бұрын
another Great video as usual.
@OdooMates
@OdooMates 2 жыл бұрын
Glad you enjoyed it
@techbi.solutions
@techbi.solutions 2 жыл бұрын
always Great video❤️❤️ can do you video about migration data! 🌷
@OdooMates
@OdooMates 2 жыл бұрын
Thanks for the support
@ridhatlati1310
@ridhatlati1310 2 жыл бұрын
thanks from tunisia
@OdooMates
@OdooMates 2 жыл бұрын
❤️❤️
@Destroman
@Destroman 2 жыл бұрын
Coolllll!!!!!!!!!!!!
@OdooMates
@OdooMates 2 жыл бұрын
@sahardagher3127
@sahardagher3127 Жыл бұрын
Hello, Can't get context when using client action!!
@RuslanSkiraUkraine
@RuslanSkiraUkraine 2 жыл бұрын
How to uset he .env file in odoo? Where to save and use system variables like Jira API key? I know the library dotenv but maybe odoo has something?
@OdooMates
@OdooMates 2 жыл бұрын
Normally in odoo, such credentials are stored in the database table. Either you can store it in a field in company model or in ir.config_parameters
@ShadHastam
@ShadHastam 8 ай бұрын
Thanks a lot
@OdooMates
@OdooMates 7 ай бұрын
Most welcome
@wildbeauty9257
@wildbeauty9257 2 жыл бұрын
Thank you sir 👍
@OdooMates
@OdooMates 2 жыл бұрын
welcome brother 😍😍😍
@ember209
@ember209 2 жыл бұрын
Great video! How do I extract the name of the model?
@OdooMates
@OdooMates 2 жыл бұрын
you can use self._name
@ember209
@ember209 2 жыл бұрын
@@OdooMates thank you
@OdooMates
@OdooMates 2 жыл бұрын
Welcome
@artiomnkkm
@artiomnkkm 2 жыл бұрын
Nice playground. Can you share it?
@OdooMates
@OdooMates 2 жыл бұрын
Sure, please drop an email to odoomates@gmail.com or share us your email id
@deepalitank5851
@deepalitank5851 2 жыл бұрын
👍👍
@OdooMates
@OdooMates 2 жыл бұрын
@quenar
@quenar Жыл бұрын
[ envayor ment ] ...
didn't manage to catch the ball #tiktok
00:19
Анастасия Тарасова
Рет қаралды 29 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 142 МЛН
🕊️Valera🕊️
00:34
DO$HIK
Рет қаралды 3,1 МЛН
We Fixed Environment Variables
7:27
Theo - t3․gg
Рет қаралды 63 М.
Odoo ORM Methods - Part1
46:14
Odoo Mates
Рет қаралды 39 М.
didn't manage to catch the ball #tiktok
00:19
Анастасия Тарасова
Рет қаралды 29 МЛН