how-to-create-a-custom-module-in-odoo-18-a-step-by-step-guide

How to Create a Custom Module in Odoo 18? A Step-by-Step Guide

The open-source ERP framework Odoo 18 enables businesses to optimize their operations through the integration of  sales and inventory management and accounting and CRM applications and additional features. Odoo gives developers access to a  flexible architecture and extensive development tools which enable efficient creation of custom business applications. Learning to develop custom module in odoo 18  stands as a basic requirement for anyone who wants to become proficient in Odoo development regardless of their experience  level. This guide provides a complete walkthrough of creating a module structure and writing Python and XML files before  showing you how to install and test your module in a local Odoo 18 environment. The final  result will enable you to create business applications that fulfill your particular requirements.

Step 1: Create the Module Folder

Go to your Odoo custom addons directory and create a new folder for your module:

				
					cd ~/odoo18/custom_addons
mkdir my_custom_module

				
			

Step 2: Create the Basic Files

Inside your new module, you need to create the following files and folders:

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

				
			
				
					File: __manifest__.py

{
	'name': 'My Custom Module',
	'version': '1.0',
	'summary': 'Simple module to demonstrate Odoo development',
	'author': 'Your Name',
	'depends': ['base'],
	'data': [
    	'security/ir.model.access.csv',
    	'views/my_model_views.xml',
	],
	'installable': True,
	'application': True,
}

				
			

Step 3: Define Your Model

				
					File: models/__init__.py




from . import my_model


file: models/my_model.py

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')


				
			

Step 4: Create Views for the Model

				
					File: views/my_model_views.xml



<odoo>
	<!-- Form View -->
	<record id="view_form_my_model" 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"/>
                	</group>
            	</sheet>
        	</form>
    	</field>
	</record>

	<!-- List View -->
	<record id="view_tree_my_model" model="ir.ui.view">
    	<field name="name">my.model.list</field>
    	<field name="model">my.model</field>
    	<field name="arch" type="xml">
        	<list>
            	<field name="name"/>
        	</list>
    	</field>
	</record>

	<!-- Action -->
	<record id="action_my_model" model="ir.actions.act_window">
    	<field name="name">My Models</field>
    	<field name="res_model">my.model</field>
    	<field name="view_mode">list,form</field>
	</record>

	<!-- Menu -->
	<menuitem id="menu_my_custom_module_root" name="My Module"/>
	<menuitem id="menu_my_model" name="My Models" parent="menu_my_custom_module_root" action="action_my_model"/>
</odoo>

				
			

Step 5: Set Up Access Rights

				
					File: security/ir.model.access.csv


id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_my_model_user,access_my_model_user,model_my_model,,1,1,1,1


				
			

Step 6: Initialize Your Module

				
					File: __init__.py

from . import models

				
			

Step 7: Install the Module in Odoo

  1. Start your Odoo 18 server:
				
					./odoo-bin -d your_database_name -u all

				
			
  1.   Go to Apps in the Odoo UI.

  2.   Click the Update Apps List (activate developer mode).

  3.   Search for your module (e.g., “My Custom Module”).

  4.   Click Install.

 Result:

You should now see a new menu item in your Odoo backend called “My Module”, where you can create and view records using your custom model.

Building a Strong Foundation with Custom Module in odoo 18

Every developer working with Odoo 18 needs to learn how to create custom modules because this skill  enables them to develop tailored solutions that match specific business needs through Odoo’s modular framework. The ability  to design business-specific solutions emerges from Odoo’s modular structure through which you can extend its functionality.  After learning about models, views, menus and access control you can begin developing adaptable applications that smoothly connect  with other Odoo modules. The mastery of these fundamental concepts enables developers to access more complex features and  extensive customization capabilities.

Picture of Adarsh

Adarsh

Hi i'm Adarsh, I'm an Odoo developer passionate about building custom business solutions using the Odoo framework. Through this blog, I share tips, tutorials, and insights from real-world development—whether it’s customizing modules, creating reports, or solving tricky errors.

Get a free quote