How to do it...

The archive feature certainly deserves its own add-on module, or at least its own Python code file. However, to keep the explanation as simple as possible, we will cram it into the models/library_book.py file:

  1. Add the abstract model for the archive feature. It must be defined in the Library Book model, where it will be used:
class BaseArchive(models.AbstractModel): 
    _name = 'base.archive' 
    active = fields.Boolean(default=True) 
 
    def do_archive(self): 
        for record in self: 
            record.active = not record.active 
  1. Now, we will edit the Library Book model to inherit the Archive model:
class LibraryBook(models.Model): 
    _name = 'library.book' 
    _inherit = ['base.archive'] 
    # ...

An upgrade of the add-on module is needed for the changes to be activated.

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

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