How to Develop a Custom Odoo Module from Scratch

Introduction:

Odoo is a powerful open-source ERP system that allows businesses to customize and extend its functionalities through modules. If you need a specific feature that Odoo doesn’t offer out-of-the-box, you can create a custom module. In this guide, we will walk through the process of developing a custom Odoo module from scratch.

Step 1: Set Up Your Odoo Development Environment

Before you start developing, you need to set up your environment correctly.

Prerequisites

  • Python 3.8+
  • PostgreSQL
  • Odoo installed (e.g., Odoo 17)
  • A code editor (VS Code, PyCharm, etc.)
  • Basic knowledge of Python and XML

If you haven’t installed Odoo yet, follow these steps:

# Update your system

sudo apt update && sudo apt upgrade -y


# Install dependencies

sudo apt install python3 python3-pip python3-venv build-essential libpq-dev -y


# Install PostgreSQL

sudo apt install postgresql -y


# Create a PostgreSQL user for Odoo

sudo -u postgres createuser -s odoo

After setting up Odoo, make sure it runs correctly before proceeding.


Step 2: Create the Module Structure

Navigate to the Odoo add-ons directory and create a new module folder.

cd /odoo/custom_addons/

mkdir my_custom_module

cd my_custom_module

Inside this folder, create the following structure:

my_custom_module/
├── __init__.py
├── __manifest__.py
├── models/
│   ├── __init__.py
│   ├── my_model.py
├── views/
│   ├── my_model_views.xml
└── security/
    ├── ir.model.access.csv

Step 3: Define the Module Metadata

Open __manifest__.py​ and define the module information:
{

    'name': 'My Custom Module',
    'version': '1.0',
    'summary': 'A custom module for demonstration purposes.',
    'author': 'Your Name',
    'depends': ['base'],
    'data': [
        'security/ir.model.access.csv',
        'views/my_model_views.xml',
    ],
    'installable': True,
    'application': True,
}

This manifest file contains essential metadata like module name, dependencies, and data files.

Step 4: Create the Model (Database Table)

Odoo models define database tables. Open models/my_model.py​ and create a model:


    

from odoo import models, fields class MyModel(models.Model):     _name = 'my.model'     _description = 'My Custom Model'     name = fields.Char(string='Name', required=True)     description = fields.Text(string='Description')     active = fields.Boolean(string='Active', default=True)


This model creates a database table my_model​ with fields for name​, description​, and active​ status.

Step 5: Define Access Rights

Odoo requires access control for models. Create security/ir.model.access.csv​ and define user permissions:

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_my_model,my.model,model_my_model,,1,1,1,1

This file grants full access to all users.

Step 6: Create the Views

Views define how models appear in the Odoo UI. Open views/my_model_views.xml​ and add:

<odoo>
    <record id="view_my_model_form" model="ir.ui.view">
        <field name="name">my.model.form</field>
        <field name="model">my.model</field>
        <field name="arch" type="xml">
            <form string="My Model">
                <sheet>
                    <group>
                        <field name="name"/>
                        <field name="description"/>
                        <field name="active"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_my_model_tree" model="ir.ui.view">
        <field name="name">my.model.tree</field>
        <field name="model">my.model</field>
        <field name="arch" type="xml">
            <tree string="My Model">
                <field name="name"/>
                <field name="active"/>
            </tree>
        </field>
    </record>

    <menuitem id="menu_my_model" name="My Custom Module" sequence="10"/>
    <menuitem id="menu_my_model_main" parent="menu_my_model" name="My Models" action="my_model_action" sequence="10"/>
</odoo>

This file defines form and tree views for the model.

Step 7: Load the Module in Odoo

Now, install the module:

  1. Restart Odoo:
    sudo systemctl restart odoo
  2. Activate Developer Mode in Odoo.
  3. Navigate to Apps > Update Apps List.
  4. Search for My Custom Module​ and click Install.


Step 8: Test the Module

After installation, go to My Models in the Odoo UI. You should be able to:

  • Create new records.
  • Edit existing records.
  • Delete records.

If anything doesn’t work, check Odoo logs:

sudo journalctl -u odoo --no-pager -n 100

Looking for server based install of odoo server, please refer my old blog with full detail.

Hope you find this helpful!!!

Contact us for odoo consulting, we will assist you..


How to Develop a Custom Odoo Module from Scratch
Ram Krishna March 14, 2025
Share this post
Sign in to leave a comment
Extracting a table create and insert statements with data from .SQL file