The server environment

The server shell provides a self reference identical to what you would find inside a method of the Users model, res.users.

As we have seen, self is a recordset. Recordsets carry with them environment information, including the user browsing the data and additional context information, such as the language and the time zone.

We can inspect the current environment with:

>>> self.env
<openerp.api.Environment object at 0xb3f4f52c>

The execution environment in self.env has the following attributes available:

  • env.cr is the database cursor being used.
  • env.user is the record for the current user.
  • env.uid is the ID for the session user. It's the same as env.user.id.
  • env.context is an immutable dictionary with a session context. ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.