← Previous

Your First Module

An Odoo module is just a folder with a manifest and some Python/XML files. Drop it in the addons path, update the apps list, and Odoo loads it like any built-in app. In this chapter you'll build the smallest module that actually does something.

The minimum structure

my_library/
├── __init__.py          # imports the models package
├── __manifest__.py      # name, version, dependencies, data files
├── models/
│   ├── __init__.py
│   └── book.py          # your model
├── security/
│   └── ir.model.access.csv   # who can read/write the model
└── views/
    └── book_views.xml   # form, list and the menu

The manifest

__manifest__.py tells Odoo what the module is and what it needs:

{
    "name": "My Library",
    "version": "1.0",
    "depends": ["base"],
    "data": [
        "security/ir.model.access.csv",
        "views/book_views.xml",
    ],
    "application": True,
}

A model

models/book.py defines a new database table through the ORM:

from odoo import fields, models

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

    name = fields.Char(required=True)
    author = fields.Char()
    published = fields.Date()

Install it

  1. Put the folder in your addons path.
  2. Turn on developer mode.
  3. Go to Apps, click Update Apps List, search My Library, and Install.

You now have a working model, a menu and a form — the foundation every larger customisation is built on.

Key takeaway

Modules keep your code separate from Odoo's core, so you can upgrade Odoo without losing your work. Everything you build from here — fields, views, automation, APIs — goes inside a module exactly like this one.

Next: models and fields in depth.

Call us WhatsApp