The environment is immutable, and so it can't be modified. But we can create a modified environment and then run actions using it.
To do so, we can make use of the following methods:
- env.sudo(user) is provided with a user record, and returns an environment with that user. If no user is provided, the Administrator superuser will be used, which allows for running specific operations, bypassing security rules.
- env.with_context(dictionary) replaces the context with a new one.
- env.with_context(key=value,...) modifies the current context setting values for some of its keys.
Additionally, we have the env.ref() function, taking a string with an external identifier and returning a record for it, as shown here: ...