with_context([context][, **overrides]) → records
Returns a new recordset with an updated context. You can pass a
dictionary as the context or use keyword arguments to override or
add context values.
# 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)
Returns a new version of the recordset that operates under the access
rights of the specified user, provided they are not the superuser.
Useful for enforcing specific user permissions when executing
operations.
with_company(company)
Returns a new instance of the recordset with the context updated to
operate under the specified company. Useful when performing actions
or retrieving data in the context of a different company than the
one currently active.
result.env.company = company
result.env.companies = self.env.companies | company
Parameters:
- company (res.company or int): Specifies the main company
in the new environment. If the current user does not have access
to the given company, attempting to use it without superuser
mode (sudo) may raise an AccessError.
with_env(env)
Returns a new instance of the recordset associated with the given
Environment.
- env (Environment): The environment to bind to the new
recordset.
sudo([flag=True])
Returns a new version of the recordset with superuser mode enabled or
disabled depending on the flag value.
- flag (bool): Optional; defaults to True. If True, enables
superuser mode; if False, disables it.