Calling onchange methods on the server side
The onchange method has a limitation: it will not be invoked when you are performing operations on the server side. onchange is invoked automatically only when the dependent operations are performed through the Odoo user interface. Yet, in a number of cases, it is important that these onchange methods are called, because they update important fields in the created or updated record. Of course, you can do the required computation yourself, but this is not always possible, as the onchange method can be added or modified by a third-party add-on module installed on the instance that you don't know about.
This recipe explains how to call the onchange methods on a record by manually invoking the onchange method before creating a record.
Getting ready
In the Changing the user that performs an action recipe, we added a Rent this book button so non-librarian users can borrow books by themselves. We now want to do the same for returning...