Building custom modules is how you extend Odoo to do exactly what your business needs. This guide walks you through creating your first Odoo module from scratch — a simple library management system.

Pre-requisites

Odoo 17 installed (see our installation guide)
Basic Python knowledge
A text editor (VS Code recommended)

STEP 1 Create Module Directory

Every Odoo module lives in the addons directory. Create a new folder for your module.

cd /opt/odoo17/odoo-custom-addons
mkdir library_management
cd library_management

STEP 2 Create __init__.py

This file tells Python this directory is a package.

# __init__.py
from . import models

STEP 3 Create __manifest__.py

The manifest file contains metadata about your module — name, description, dependencies, and which files to load.

# __manifest__.py
{
    'name': 'Library Management',
    'version': '17.0.1.0.0',
    'summary': 'Manage library books and members',
    'description': 'A simple library management module',
    'author': 'Your Name',
    'category': 'Services',
    'depends': ['base'],
    'data': [
        'security/ir.model.access.csv',
        'views/book_views.xml',
        'views/menu.xml',
    ],
    'installable': True,
    'application': True,
}

STEP 4 Create the Model

mkdir models
touch models/__init__.py
# models/__init__.py
from . import book
# models/book.py
from odoo import models, fields

class LibraryBook(models.Model):
    _name = 'library.book'
    _description = 'Library Book'

    name = fields.Char(string='Title', required=True)
    author = fields.Char(string='Author')
    isbn = fields.Char(string='ISBN')
    date_published = fields.Date(string='Published Date')
    pages = fields.Integer(string='Number of Pages')
    category = fields.Selection([
        ('fiction', 'Fiction'),
        ('non_fiction', 'Non-Fiction'),
        ('science', 'Science'),
        ('technology', 'Technology'),
    ], string='Category')
    is_available = fields.Boolean(string='Available', default=True)

STEP 5 Create Security Access Rules

mkdir security
# security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_library_book,access_library_book,model_library_book,base.group_user,1,1,1,1

STEP 6 Create Views

mkdir views
<!-- views/book_views.xml -->
<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Tree View -->
    <record id="view_library_book_tree" model="ir.ui.view">
        <field name="name">library.book.tree</field>
        <field name="model">library.book</field>
        <field name="arch" type="xml">
            <tree>
                <field name="name"/>
                <field name="author"/>
                <field name="isbn"/>
                <field name="category"/>
                <field name="is_available"/>
            </tree>
        </field>
    </record>

    <!-- Form View -->
    <record id="view_library_book_form" model="ir.ui.view">
        <field name="name">library.book.form</field>
        <field name="model">library.book</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <group>
                        <group>
                            <field name="name"/>
                            <field name="author"/>
                            <field name="isbn"/>
                        </group>
                        <group>
                            <field name="date_published"/>
                            <field name="pages"/>
                            <field name="category"/>
                            <field name="is_available"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>
</odoo>

STEP 7 Create Menu Items

<!-- views/menu.xml -->
<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <menuitem id="library_menu_root" name="Library" sequence="10"/>

    <record id="action_library_book" model="ir.actions.act_window">
        <field name="name">Books</field>
        <field name="res_model">library.book</field>
        <field name="view_mode">tree,form</field>
    </record>

    <menuitem id="library_book_menu" name="Books"
              parent="library_menu_root"
              action="action_library_book" sequence="10"/>
</odoo>

STEP 8 Install and Test

Restart Odoo and update the module list:

sudo systemctl restart odoo17

In the Odoo web interface, go to Apps, remove the “Apps” filter from search, search for “Library Management” and click Install. Your module is now live with a full CRUD interface.

Share this article

Comments

Join the discussion. Got a question, found an issue, or want to share your experience?

Leave a Comment

Your email stays private. We just use it for replies.

Nothing to preview yet.

Use **bold**, *italic*, `code`, ```code blocks```, [link](url), > quote, - list