Building a Custom Odoo Addon, Modules and Apps - 01 Odoo Development Environment using Docker
Table of Content
Odoo is an open-source ERP (Enterprise Resource Planning) platform that offers a suite of business applications, including CRM, inventory, sales, accounting, and more. Its modular architecture allows businesses to deploy only the features they need, making it highly customizable and scalable.
Odoo's popularity stems from its user-friendly interface, active community, and the flexibility to adapt to diverse industries.
Unlike proprietary ERP systems, Odoo’s open-source nature provides transparency and cost-efficiency.
With over 7 million users worldwide, Odoo holds a significant share in the ERP market, particularly among small to medium-sized enterprises seeking affordable, robust solutions.
At Medevel.com, we leverage Odoo to deliver tailored ERP solutions for our clients. We specialize in developing custom modules and apps that extend Odoo's functionality to meet unique business requirements. Our services also include custom installations and expert consultation to ensure seamless integration and optimal performance.
By harnessing the power of Odoo’s open-source platform, we provide cost-effective and flexible solutions for industries ranging from healthcare to retail. Our goal is to empower businesses with efficient, scalable, and user-friendly ERP systems.
In this tutorial, we will walk through setting up an Odoo 17 development environment using Docker. This setup will provide a clean, isolated, and reproducible environment for developing custom addons, modules, and apps.
1. Prerequisites
Before we begin, ensure you have the following installed on your system:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
- Git (optional for version control): Install Git
2. Creating the Docker Compose Configuration
Create a docker-compose.yml
file in your project directory. This file will define the Odoo and PostgreSQL services.
docker-compose.yml
version: '3.1'
services:
db:
image: postgres:15
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=odoo
volumes:
- ./odoo-db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
odoo:
image: odoo:17
depends_on:
- db
ports:
- "8069:8069"
volumes:
- ./custom-addons:/mnt/extra-addons
- ./config:/etc/odoo
- ./data:/var/lib/odoo
environment:
- HOST=db
- USER=odoo
- PASSWORD=odoo
volumes:
odoo-db-data:
Explanation of Services
db
Service:- Uses the PostgreSQL 15 image.
- Sets the database name, user, and password.
- Persists data using the
odoo-db-data
volume.
odoo
Service:- Uses the Odoo 17 image.
- Mounts:
custom-addons
for custom module development.config
for Odoo configuration files.data
for storing Odoo’s runtime data.
- Connects to the
db
service.
3. Setting Up Directory Structure
Create the following directories in your project folder:
mkdir custom-addons
mkdir config
mkdir data
Your project directory should now look like this:
project-folder/
├── docker-compose.yml
├── custom-addons/
├── config/
└── data/
4. Creating the Odoo Configuration File
Create a configuration file for Odoo inside the config
directory.
config/odoo.conf
[options]
addons_path = /mnt/extra-addons
admin_passwd = admin
db_host = db
db_port = 5432
db_user = odoo
db_password = odoo
logfile = /var/lib/odoo/odoo.log
Explanation of Options
addons_path
: Path to the custom addons directory.admin_passwd
: Master password for managing databases.db_host
,db_port
,db_user
,db_password
: PostgreSQL connection settings.logfile
: Path to Odoo’s log file.
5. Starting the Odoo and PostgreSQL Containers
Now that everything is set up, start the containers with:
docker-compose up --build -d
Verify the Containers
Check if the containers are running:
docker ps
You should see both the Odoo and PostgreSQL containers listed.
6. Accessing the Odoo Interface
- You should see the Odoo setup page.
- Create a new database:
- Database Name: Choose a name (e.g.,
odoo_dev
). - Email: Your email.
- Password: Your desired admin password.
- Master Password: Use the master password from
config/odoo.conf
(admin
).
- Database Name: Choose a name (e.g.,
Open your browser and go to:
http://localhost:8069
7. Creating a Custom Addon Directory
To develop custom addons, place them inside the custom-addons
directory.
Example Structure for a Custom Addon
custom-addons/
└── welcome_message/
├── __init__.py
├── __manifest__.py
└── controllers/
├── __init__.py
└── main.py
Sample Custom Addon: welcome_message
custom-addons/welcome_message/controllers/main.py
from odoo import http
from odoo.http import request
class WelcomeMessage(http.Controller):
@http.route('/welcome', type='http', auth='public', website=True)
def welcome(self):
return "<h1>Welcome to Odoo Custom Addon!</h1>"
custom-addons/welcome_message/controllers/__init__.py
from . import main
custom-addons/welcome_message/__manifest__.py
{
'name': 'Welcome Message',
'version': '1.0',
'category': 'Tools',
'summary': 'Displays a simple welcome message',
'depends': ['base', 'web'],
'data': [],
'installable': True,
'application': True,
}
custom-addons/welcome_message/__init__.py
from . import controllers
8. Tips for Odoo Development
Updating Apps List:
- Go to Apps > Update Apps List to refresh the list after adding new addons.
Rebuilding Containers:
If you make changes to docker-compose.yml
or config
, restart containers:
docker-compose down
docker-compose up --build -d
Logs: View Odoo logs to debug issues:
docker-compose logs -f odoo
Developer Mode: Enable developer mode by adding ?debug=1
to the URL:
http://localhost:8069/web?debug=1
9. Conclusion
You now have a fully functional Odoo 17 development environment using Docker. This setup allows you to:
- Develop custom addons in the
custom-addons
directory. - Manage Odoo configuration with the
config/odoo.conf
file. - Easily manage and scale your environment with Docker Compose.
Happy coding, and enjoy building your Odoo addons! 😊