The execution environment
The server shell provides a self
reference similar to what you would find inside a method of the res.users
user model.
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.
In the following sections, we will learn about the attributes made available in the execution environment, the usefulness of the environment context, and how to modify this context.
Environment attributes
We can inspect the current environment with the following code:
>>> 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 asenv.user.id
.env.context
is an immutable dictionary with a session context.
The environment also...