How it works...

Steps 1 and 2 carry out the extension of the business logic. We define a model that extends library.books and redefines the make_borrowed() and make_available() methods. In the last line of both methods, the result that was implemented by the parent class is returned:

return super(LibraryBook, self).make_borrowed()

In the case of Odoo models, the parent class is not what you'd expect by looking at the Python class definition. The framework has dynamically generated a class hierarchy for our recordset, and the parent class is the definition of the model from the modules that we depend on. So, the call to super() brings back the implementation of library.book from my_module. In this implementation, make_borrowed() changes the state of book to Borrowed. So, calling super will invoke the parent method and it will set the book state to Borrowed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset