Defining onchange with the compute method
In the last two recipes, we have seen how to define and call the onchange method. We have also seen its limitation, which is that it can be invoked automatically only from the user interface. As a solution to this problem, Odoo v13 introduced a new way to define
onchange behavior. In this recipe, we will see how you can use the
compute method to produce behavior like the
For this recipe, we will use the
my_library module from the previous recipe. We will replace the
onchange method of
library.return.wizard with the compute method.
How to do it...
Follow these steps to modify the
onchange method with the
@api.depends('borrower_id') def onchange_member(self): ...
- Add the