
The Context
What is it?
Context is a list of values used to transfer information to a method (a code function). It is often used to set default values to new records by taking information from the initial record.
With Studio, you can define a context on any many2one or many2many field.
Example : Add a context to a field You create a many2one "x_studio_partner_id" on the contacts in order to define which other contact B is the partner of your partner A. If the partner B does not exist yet and you're creating it on the fly, you want the field on contact B to be completed automatically with partner A on creation. To get this result, you can open studio and add a context to your field : {'default_x_studio_partner_id' : active_id} |
Example : Window Actions Contexts are also defined on window actions. So when you create a record from a view default values will be applied. This is best explained by looking at a smart button. If you create a sale order but you came from the smart button "Quotations and Sales" on a specific contact, your new sale order will be directly have this contact as default value. This is visible in the action : |
Why is it useful?
To pass on values to new records that are created, simplify the encoding for users and limit human errors.
Extra documentation