How to do it...

To add a new Model, we add a Python file describing it and then upgrade the addon module (or install it, if it was not already done). The paths used are relative to our addon module location (for example, ~/odoo-dev/local-addons/my_module/):

  1. Add a Python file to the models/library_book.py module with the following code:
from odoo import models, fields     
class LibraryBook(models.Model): 
    _name = 'library.book' 
    name = fields.Char('Title', required=True) 
    date_release = fields.Date('Release Date')
author_ids = fields.Many2many(
'res.partner',
string='Authors'
)
  1. Add a Python initialization file with code files to be loaded by the models/__init__.py module with the following code:
from . import library_book 
  1. Edit the module Python initialization file to have the models/ directory loaded by the module:
from . import models
  1. Upgrade the Odoo module, either from the command line or from the apps menu in the user interface. If you look closely at the server log while upgrading the module, you should see this line:
odoo.modules.registry: module my_module: creating or updating database table

After this, the new library.book model should be available in our Odoo instance. If we have the technical tools activated, we can confirm that by looking it up at Settings | Technical | Database Structure | Models.