The environment provides contextual information used by the server. Every recordset carries its execution environment in
self.env with these attributes:
env.cr: This is the database cursor being used.
env.uid: This is the ID for the session user.
env.user: This is the record for the session user.
env.context: This is an immutable dictionary with a session context.
The environment is immutable, and so it can't be modified. But we can create modified environments and then run actions using them. These methods can be used for that:
env.sudo(user): If this is provided with a user record, it returns an environment with that user. If no user is provided, the administrator superuser will be used, which allows running specific queries ...