Altering the Environment
with_context([context][, **overrides]) → records.
This method produces a new record set with an extra context.
Eg:
# current context is {'key1': True}
result1 = records.with_context({}, key2=True)
# result1._context is {'key2': True}
result2 = records.with_context(key2=True)
# result2._context is {'key1': True, 'key2': True}
with_user(user)
Return a new version of this record set linked to the specified in non-superuser mode if the user is not the superuser.
with_company(company)
Return a new instance of this recordset with updated context, so that:
result.env.company = company
result.env.companies = self.env.companies | company
Parameters:
company (res_company or int) – The major company in the new environment.
If a current user is using an unauthorised company, attempting to access the company(ies) in the environment may result in an AccessError if not done in a sudoed environment.
with_env(env)
Return a new version of this record set that is tied to the environment specified.
Parameters:
env (Environment)
sudo([flag=True])
Returns a new version of this record set with superuser mode enabled or disabled, depending on the flag. The current user is unaffected by the superuser mode, which merely skips access rights checks.