Odoo 17 Development Book- Altering the Environment

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.

whatsapp
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