Skip to content

Odoo Git Deployment: Deploy Custom Modules with Git

DeployMonkey Team · March 22, 2026 10 min read

Why Git for Odoo Deployment?

Manual module deployment (copy files via SCP/FTP, restart Odoo) is error-prone, unversioned, and impossible to rollback. Git-based deployment gives you version history, branch-based environments (staging/production), automated deployment pipelines, and instant rollback to any previous version.

Repository Structure

# Recommended structure
odoo-custom-addons/
├── .gitignore
├── requirements.txt          # Python dependencies
├── module_one/
│   ├── __manifest__.py
│   ├── __init__.py
│   ├── models/
│   ├── views/
│   ├── security/
│   └── tests/
├── module_two/
│   └── ...
└── module_three/
    └── ...

.gitignore for Odoo

# .gitignore
*.pyc
__pycache__/
*.pyo
*.egg-info/
.eggs/
*.egg
.venv/
venv/
node_modules/
.idea/
.vscode/
*.swp
*.swo

Deployment Workflow

Simple: Pull and Restart

# On the server:
cd /opt/odoo/custom-addons
git pull origin main
sudo systemctl restart odoo

# If module update needed:
sudo -u odoo /opt/odoo/venv/bin/python3 /opt/odoo/odoo/odoo-bin \
    -d production -u module_name --stop-after-init
sudo systemctl restart odoo

Better: Deployment Script

#!/bin/bash
# deploy.sh
set -e

BRANCH=${1:-main}
ADDONS_DIR="/opt/odoo/custom-addons"
MODULES_TO_UPDATE=${2:-""}

# 1. Backup
echo "Creating backup..."
pg_dump -U odoo production | gzip > /opt/backups/pre-deploy-$(date +%Y%m%d_%H%M%S).sql.gz

# 2. Pull latest code
echo "Pulling $BRANCH..."
cd $ADDONS_DIR
git fetch origin
git checkout $BRANCH
git pull origin $BRANCH

# 3. Install Python dependencies
source /opt/odoo/venv/bin/activate
pip install -r requirements.txt -q

# 4. Update modules if specified
if [ -n "$MODULES_TO_UPDATE" ]; then
    echo "Updating modules: $MODULES_TO_UPDATE"
    sudo systemctl stop odoo
    sudo -u odoo /opt/odoo/venv/bin/python3 /opt/odoo/odoo/odoo-bin \
        -d production -u $MODULES_TO_UPDATE --stop-after-init
fi

# 5. Restart Odoo
echo "Restarting Odoo..."
sudo systemctl restart odoo

# 6. Verify
sleep 5
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8069 | grep -q 200; then
    echo "Deploy successful!"
else
    echo "WARNING: Odoo may not be responding. Check logs."
fi

Branch Strategy

# Recommended branches:
main        → production deployment
staging     → staging/testing environment
develop     → active development
feature/*   → feature branches (merged to develop)

Rollback

# Instant code rollback:
git log --oneline -10  # Find the commit to rollback to
git checkout 
sudo systemctl restart odoo

# If database changes need rollback:
# Restore pre-deployment backup
gunzip -c /opt/backups/pre-deploy-20260322.sql.gz | sudo -u postgres psql production

Webhook-Based Auto-Deploy

# Set up a webhook receiver (Flask/FastAPI):
# When GitHub/GitLab pushes to main → trigger deploy.sh

# Or use DeployMonkey's built-in Git CI/CD:
# Connect your repo → push to main → automatic deployment

DeployMonkey Git Deployment

DeployMonkey includes built-in Git CI/CD: connect your repository, push code, and modules deploy automatically. Pre-deployment backups, post-deployment health checks, and one-click rollback are included. No deployment scripts to maintain.