Define onchange methods
When writing Odoo models, it is often the case that some fields are interrelated. We have seen how to specify constraints between fields in the Add constraint validations to a Model recipe in Chapter 4, Application Models. This recipe illustrates a slightly different concept—onchange methods are called when a field is modified in the user interface to update the values of other fields of the record in the web client, usually in a form view.
We will illustrate this by providing a wizard similar to the one defined in the preceding recipe, Write a wizard to guide the user, but which can be used to record loan returns. When the member is set on the wizard, the list of books is updated to the books currently borrowed by the member. While we are demonstrating onchange methods on a TransientModel
, these features are also available on normal Models
.
Getting ready
If you want to follow the recipe, make sure you have the my_module
addon from Chapter 3, Creating Odoo Modules, with...