Odoo 16 Development Book

Altering the Environment

with_context([context][, **overrides]) → records.

This method generates a new recordset with an additional 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)

If the user is not the superuser, return a new version of this recordset connected to the specified in non-superuser mode.

with_company(company)

Return a new instance of this recordset with altered context, such that:

result.env.company = company
result.env.companies = self.env.companies | company

Parameters:

company (res_company or int) – The primary company in the new environment.

If a current user is using an unauthorized company, accessing the company(ies) on the environment may result in an AccessError if not done in a sudoed environment.

with_env(env)

Return a new version of this recordset that is bound to the environment provided.

Parameters:

env (Environment)

sudo([flag=True])

Depending on the flag, returns a new version of this recordset with superuser mode enabled or disabled. The superuser mode has no effect on the current user and simply bypasses access rights checks.

location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message