How to do it...

For this recipe, we will use the code from the previous recipe. As an example, we will increase the existing book price by $10 USD. Note that you might using another currency based on company configurations.

Follow these steps to invoke the Python method from the XML file:

  1. Add the _update_book_price() method in the library.book model:
@api.model
def _update_book_price(self):
all_books = self.search([])
for book in all_books:
book.cost_price += 10
  1. Add <function> in the data XML file:
<function model="library.book" name="_update_book_price"/>
..................Content has been hidden....................

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