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

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024
  • 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 года назад +3

    For this explaination video, i suggest you to use debugger of pycharm, it will easily show full of env variable.

    • @OdooMates
      @OdooMates  2 года назад +1

      thanks brother for suggestion

  • @adrianseguratrista5666
    @adrianseguratrista5666 2 года назад +1

    Greetings from Cuba. Thank you very much.

    • @OdooMates
      @OdooMates  2 года назад

      Glad it.helped ❤️❤️❤️

  • @dipak-45-w8f
    @dipak-45-w8f Год назад +1

    Very nice teaching great explanations about environment

  • @elmehdielouali5850
    @elmehdielouali5850 2 года назад +1

    good job, thanks for sahring the module, I am grateful

  • @nadeemkazi2092
    @nadeemkazi2092 2 года назад +1

    Thanks odoo mates..its useful info.

    • @OdooMates
      @OdooMates  2 года назад +1

      Welcome brother ❤️❤️

  • @aunnfriends
    @aunnfriends 2 года назад +1

    A very beautiful playground!

  • @abdussattarbhuiyan4566
    @abdussattarbhuiyan4566 2 года назад +1

    another Great video as usual.

  • @ridhatlati1310
    @ridhatlati1310 2 года назад +1

    thanks from tunisia

  • @techbi.solutions
    @techbi.solutions 2 года назад +1

    always Great video❤️❤️
    can do you video about migration data! 🌷

    • @OdooMates
      @OdooMates  2 года назад

      Thanks for the support

  • @hectorherrera4193
    @hectorherrera4193 2 года назад +1

    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

  • @sahardagher3127
    @sahardagher3127 Год назад

    Hello,
    Can't get context when using client action!!

  • @ShadHastam
    @ShadHastam 8 месяцев назад

    Thanks a lot

  • @Destroman
    @Destroman 2 года назад +1

    Coolllll!!!!!!!!!!!!

  • @mohamedboudekak8574
    @mohamedboudekak8574 2 года назад +1

    Hello,
    Greate video as always, is it possible to share the odoo playground model.
    Thanks

  • @RuslanSkiraUkraine
    @RuslanSkiraUkraine 2 года назад +1

    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 года назад +1

      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

  • @wildbeauty9257
    @wildbeauty9257 2 года назад

    Thank you sir 👍

    • @OdooMates
      @OdooMates  2 года назад

      welcome brother 😍😍😍

  • @artiomnkkm
    @artiomnkkm 2 года назад +1

    Nice playground. Can you share it?

    • @OdooMates
      @OdooMates  2 года назад +1

      Sure, please drop an email to odoomates@gmail.com or share us your email id

  • @ember209
    @ember209 2 года назад +1

    Great video! How do I extract the name of the model?

    • @OdooMates
      @OdooMates  2 года назад +1

      you can use self._name

    • @ember209
      @ember209 2 года назад +1

      @@OdooMates thank you

    • @OdooMates
      @OdooMates  2 года назад

      Welcome

  • @deepalitank5851
    @deepalitank5851 2 года назад

    👍👍

  • @quenar
    @quenar Год назад

    [ envayor ment ] ...