ERPGAP Blog / How to Setup an Odoo development environment

How to Setup an Odoo development environment


How to Setup an Odoo 15.0 development environment on Ubuntu 22.04 Jammy Jellyfish


How to Setup an Odoo 15.0 development environment on Ubuntu 22.04 Jammy Jellyfish aims to help new Odoo developers to start fast understanding the several components you need too develop in Odoo. You will learn how to use Python virtualenv, Postgresql server, install python3.8 on Ubuntu 22.04, Install wkhtmltopdf, install node.js and nvm and last but not least install and configure Nginx server as an Odoo reverse proxy.

Install Odoo

# update packages
sudo apt update && sudo apt upgrade -y
# add deadsnakes repo because we need python 3.8
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
# install dependencies for pip to compile source python packages
sudo apt install python3.8 python3.8-dev python3.8-distutils python3.8-lib2to3 python3-virtualenv libpq-dev libldap2-dev libssl-dev libsasl2-dev libjs-underscore
fonts-dejavu-core fonts-freefont-ttf fonts-freefont-otf fonts-noto-core fonts-inconsolata fonts-font-awesome fonts-roboto-unhinted gsfonts p7zip-full -y
# shallow clone Odoo CE to save space
git clone --branch 15.0 --depth=1 https://github.com/odoo/odoo.git ~/git/odoo/15.0
# create and activate python virtual environment
virtualenv --python=python3.8 ~/envs/15.0
source ~/envs/15.0/bin/activate
# install python libs
pip install -r ~/git/odoo/15.0/requirements.txt
# make sure it works
~/git/odoo/15.0/odoo-bin --version

Install postgresql server

sudo apt install postgresql -y
# create a super user for your nix user to connect using unix sockets
sudo -H -u postgres -- createuser --superuser $USER
# let's create a new db with test data and CRM app
~/git/odoo/15.0/odoo-bin -d v15_test --stop-after-init --no-http -i crm

Install wkhtmltopdf

This is the component that will create the reports converting html to pdf.

wget https://github.com/wkhtmltopdf/packaging/files/8632951/wkhtmltox_0.12.5-1.jammy_amd64.zip
7z x wkhtmltox_0.12.5-1.jammy_amd64.zip
sudo dpkg -i wkhtmltox_0.12.5-1.jammy_amd64.deb
sudo apt install --fix-broken

Install node and node-less

Odoo uses node for processing css.

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install 14
npm install -g less rtlcss rtl-detect clean-css postcss-ltr-rtl-detect

Contact Us

Install Nginx

sudo apt install nginx

Just replace file /etc/nginx/sites-available/default by:

upstream odoo_srv {
    server 127.0.0.1:8069 weight=1 fail_timeout=0;
}

upstream odoo_long {
    server 127.0.0.1:8072 weight=1 fail_timeout=0;
}

server {
    listen 80 default_server;
    server_name www.odoo.local;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    proxy_buffers 16 64k;
    proxy_buffer_size 128k;
    client_max_body_size 4M;

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_http_version 1.1;
    gzip_min_length 256;
    gzip_types
        text/css
        text/javascript
        text/xml
        text/plain
        image/bmp
        image/gif
        image/jpeg
        image/jpg
        image/png
        image/svg+xml
        image/x-icon
        application/javascript
        application/json
        application/rss+xml
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-javascript
        application/xml
        application/xml+rss;

    location ~* ^/([^/]+/static/|web/(css|js)/|web/image/|web/content/|website/image/) {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 30d;
        proxy_pass http://odoo_srv;
    }


    location / {
        proxy_pass http://odoo_srv;
        proxy_connect_timeout 360s;
        proxy_send_timeout 360s;
        proxy_read_timeout 360s;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
        proxy_redirect off;
    }

    location /longpolling {
        proxy_pass http://odoo_long;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
        proxy_redirect off;
    }

}

Now reload configuration:

sudo nginx -t && sudo systemctl reload nginx.service

# let's run the server and text on port 80
~/git/odoo/15.0/odoo-bin -d v15_test --db-filter ^v15_test$ --workers 3

Contact Us

Check all details on Youtube


Other articles



Vuestorefront Customer Case Gevenhout

Oral e-Health Management Platform

Odoo the ERP for furniture manufacturing