The new Library Member model should be in its own Python code file, but to keep the explanation as simple as possible, we will reuse the models/library_book.py file:
- Add the new model, inheriting from res.partner:
class LibraryMember(models.Model): _name = 'library.member' _inherits = {'res.partner': 'partner_id'} partner_id = fields.Many2one( 'res.partner', ondelete='cascade')
- Next, we will add the fields that are specific to Library Members:
# class LibraryMember(models.Model): # ... date_start = fields.Date('Member Since') date_end = fields.Date('Termination Date') member_number = fields.Char()
date_of_birth = fields.Date('Date of birth')
Now, we should upgrade the add-on module to activate the changes.