Calling a method with a modified context
context
is part of the environment of a recordset. It is used to pass extra information, such as the time zone and the language of the user, from the user interface. You can also use the context to pass the parameters specified in the actions. Several methods in the standard Odoo add-ons use the context to adapt their business logic based on these context values. It is sometimes necessary to modify the context on a recordset
value to get the desired results from a method call or the desired value for a computed field.
This recipe will show you how to change the behavior of a method based on values in the environmental context.
Getting ready
For this recipe, we will use the my_hostel
module from the previous recipe. On the form view of the hostel.room
model, we will add a button to remove room members. If a regular resident of a hostel removes other occupants from their assigned room without permission or authorization, it could create...