How to do it...

To extend the business logic in the library.book model, you need to perform the following steps:

  1. From my_module_return, we want to set date_return in the books record when we change the book status to Borrowed. For this, we will override the make_borrowed method from the my_module_return module:
def make_borrowed(self):
day_to_borrow = self.category_id.max_borrow_days or 10
self.date_return = fields.Date.today() + timedelta(days=day_to_borrow)
return super(LibraryBook, self).make_borrowed()
  1. We also want to reset the date_return when the book is returned and available to borrow, so we will override the make_available method to reset the date:
    def make_available(self):
self.date_return = False
return super(LibraryBook, self).make_available()
..................Content has been hidden....................

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