Defining onchange methods
When writing business logic, it is often the case that some fields are interrelated. We looked at how to specify constraints between fields in the Adding constraint validations to a model recipe in Chapter 4, Application Models. This recipe illustrates a slightly different concept. Here,
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 Writing a wizard to guide the user recipe, but that can be used to record book returns. When a member is set in the wizard, the list of books is updated to the books that are currently borrowed by the member. While we are demonstrating
onchange methods on
TransientModel, these features are also available on normal models.
For this recipe, we will use the
my_library module from the Writing a wizard to guide...