O'Reilly logo

Odoo Development Essentials by Daniel Reis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The execution environment

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required