Eclipse PyDev

How to Setup Odoo Development Environment on Ubuntu 22.04 Jammy JellyFish

In this tutorial, I will go through how to set up the Odoo development environment on Ubuntu 22.04 with Eclipse as the IDE. This tutorial is valid for all Odoo versions from 8.0 to 16.0 and is effective for a fresh Ubuntu 22.04 Desktop with no pre-installed tools e.g. JDK, Python, or Eclipse. You may skip to the next step if you have already installed any of the above-mentioned tools.

Please note that If you want to install Odoo for your server, you may read other posts of mine:

  1. Install Odoo 8 on Ubuntu 22.04 Server
  2. Install Odoo 9 on Ubuntu 22.04 Server
  3. Install Odoo 10 on Ubuntu 22.04 Server
  4. Install Odoo 11 on Ubuntu 22.04 Server
  5. Install Odoo 12 on Ubuntu 22.04 Server
  6. Install Odoo 13 on Ubuntu 22.04 Server
  7. Install Odoo 14 on Ubuntu 22.04 Server
  8. Install Odoo 15 on Ubuntu 22.04 Server
  9. Install Odoo 16 on Ubuntu 22.04 Server

Now, let’s start with my step-by-step instructions to setup your Odoo development environment with Eclipse PyDev and multiple versions of Python and PostgreSQL. This post is so long that may take 2 hours or more. Please be patient!

Prerequisites

To setup Odoo development environment, we need to install various package and software to meet requirements by Python versions and PostgreSQL version.

As usual, we always update our system for latest fixes and updates before any installation

sudo apt update
sudo apt dist-upgrade

Install required packages

sudo apt install make build-essential libreadline-dev \
wget curl llvm libssl-dev zlib1g-dev libbz2-dev  \
libsqlite3-dev libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev libgdbm-dev \
libnss3-dev libedit-dev libc6-dev python-setuptools \
libxml2-dev libxslt1-dev libsasl2-dev python3-dev \
libldap2-dev libjpeg-dev python2-dev libpq-dev

Reboot your machine then proceed for less compiler installation

Install Less Compiler

Odoo 9 and Odoo 10 and Odoo 11 require less compiler to compile less to css. Here is how we install less

# Install nodejs
sudo apt install nodejs
# Install Nodejs package manager
sudo apt install npm
# update for the latest npm
sudo npm install -g npm

# install less compiler using npm
sudo npm install -g less less-plugin-clean-css

Install wkhtmltopdf

Odoo generates PDF from HTML, that’s why we need the wkhtmltopdf.

Download wkhtmltopdf

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb

Install wkhtmltopdf

sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
# force install dependencies
sudo apt -f install

Install PostgreSQL Database Management System

As each Odoo version supports a limited PostgreSQL version. So, we decide to install multiple versions of PostgreSQL to support various Odoo versions from 8.0 to 16.0. In summary:

Add PostgreSQL PPA

# Create the file repository configuration: 
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
 
# Import the repository signing key: 
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg 
 
# Update the package lists: 
sudo apt update
# Upgrade the system for latest fixes and updates
sudo apt dist-upgrade

Install multiple versions of PostgreSQL

In this section, we will install four versions of PostgreSQL that run on different ports:

  1. PostgreSQL 14: port 5432 (default port), to support Odoo 16
  2. PostgreSQL 9.6: port 5433, to support Odoo 8, Odoo 9
  3. PostgreSQL 10: port 5434, to support odoo 10, Odoo 11
  4. PostgreSQL 12: port 5435, to support Odoo 12, Odoo 13, Odoo 14, Odoo 15

IMPORTANT: the installation order below is IMPORTANT!

Install PostgreSQL 14

sudo apt install postgresql postgresql-contrib

Install PostgreSQL 9.6

sudo apt install postgresql-9.6 postgresql-contrib-9.6 postgresql-client-9.6

Install PostgreSQL 10

sudo apt install postgresql-10 postgresql-client-10

Install PostgreSQL 12

sudo apt install postgresql-12 postgresql-client-12

Create Role for development

In this section, we will create roles for each PostgreSQL version that have the same name as your Linux / Ubuntu account’s. In my case, I will create role name david for those four versions as my Ubuntu login name is david. You should adjust the commands according to your environment.

Create development role for PostgreSQL 14

sudo -u postgres createuser --interactive -p 5432

When the system asks you for access rights configuration for the new role, please input as below

Add new PostgreSQL role for Odoo development

The command above create a role named david that is NOT a superuser but has rights to create database and new roles for PostgreSQL 14.

You now can start do similarly for other versions of PostgreSQL

Create development role for PostgreSQL 9.6

sudo -u postgres createuser --interactive -p 5433

Create development role for PostgreSQL 10

sudo -u postgres createuser --interactive -p 5434

Create development role for PostgreSQL 12

sudo -u postgres createuser --interactive -p 5435

Download Odoo source code from GitHub

In this section, I will guide you to have all Odoo source code from 8 to 16 in fastest way

Download Odoo 8 from GitHub

git clone -b 8.0 https://github.com/odoo/odoo.git ~/git/odoo8

Please note that if you want your Odoo to support later PostgreSQL versions (i.e. PostgreSQL 10, PostgreSQL 12), you could clone the Viindoo’s fork instead, using the command below:

git clone -b 8.0 https://github.com/Viindoo/odoo.git ~/git/odoo8

If you want to use git over SSH for security and performance, you may refer to my instructions on how to clone github repository over SSH.

Copy Odoo 8 and Checkout for other Odoo versions

Instead of doing clone again which takes lots of time, we can just copy the downloaded odoo8 and checkout the branch 9.0.

# copy ~/git/odoo8 to ~/git/odoo9
cp -R ~/git/odoo8 ~/git/odoo9
# checkout the branch 9.0 for Odoo 9
cd ~/git/odoo9
git checkout 9.0

Now, do the same for Odoo 10 and 11 and 12 and 13 and 14 and 15 and 16 then you are done.

# for Odoo 10
cp -R ~/git/odoo8 ~/git/odoo10
cd ~/git/odoo10
git checkout 10.0
# for Odoo 11
cp -R ~/git/odoo8 ~/git/odoo11
cd ~/git/odoo11
git checkout 11.0
# for Odoo 12
cp -R ~/git/odoo8 ~/git/odoo12
cd ~/git/odoo12
git checkout 12.0
# for Odoo 13
cp -R ~/git/odoo8 ~/git/odoo13
cd ~/git/odoo13
git checkout 13.0
# for Odoo 14
cp -R ~/git/odoo8 ~/git/odoo14
cd ~/git/odoo14
git checkout 14.0
# for Odoo 15
cp -R ~/git/odoo8 ~/git/odoo15
cd ~/git/odoo15
git checkout 15.0
# for Odoo 16
cp -R ~/git/odoo8 ~/git/odoo16
cd ~/git/odoo16
git checkout 16.0

Install and Setup Virtual Environment for Python 2.7 and Python 3

With Odoo 8, Odoo9 and Odoo 10, we are required to use Python 2.7 because these Odoo versions do not support Python 3. For Odoo versions after 10 then, in my experience, we will use Python versions for Odoo are as follows:

Odoo vs. Python Versions map

  • Odoo 11: Python 3.6
  • Odoo 12 and 13: Python 3.7
  • Odoo 14 and 15: Python 3.8
  • Odoo 16: Python 3.10

Install Python

The installation is quite easy by following my post of Installing multiple Python versions on Ubuntu 22.04. In summary:

Install Python 2

# install Python 2
sudo apt install python2 -y
# install pip for Python2
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
python2 get-pip.py
# install virtual environment for Python 2
pip2 install virtualenv

Install Python 3.6 from source

wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
tar -xzf Python-3.6.15.tgz
cd Python-3.6.15
./configure --enable-optimizations --with-lto --with-pydebug
make -j 4  # adjust 4 for number of your CPU cores
sudo make altinstall

Install Python 3.7, 3.8, 3.10

# Add Deadsnakes PPA
sudo add-apt-repository ppa:deadsnakes/ppa
# Install Python 3
sudo apt install python3.7 python3.7-dev \
python3.8 python3.8-dev
# Install Virtual Environment
sudo apt install python3.7-venv python3.8-venv python3.10-venv

Create and Manage Virtual Environments

According to the assumption of Odoo vs. Python versions map, the virtual environments should be created as below:

Create Python 2 Virtual Environment for Odoo 8, 9, 10

Here are commands to create virtual environment and required libraries for Odoo 8

# create virtual environment named odoo8 in ~/python-venv/2.7/odoo8
virtualenv ~/python-venv/2.7/odoo8
# activate the virtual environment
source ~/python-venv/2.7/odoo8/bin/activate
# upgrade pip for the latest version
pip install --upgrade pip
# install Odoo 8's required libraries
pip install -r ~/git/odoo8/requirements.txt
# deactivate the virtual environment
deactivate

Here are similar commands to create virtual environment and required libraries for Odoo 9

virtualenv ~/python-venv/2.7/odoo9
source ~/python-venv/2.7/odoo9/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo9/requirements.txt
deactivate

Here are similar commands to create virtual environment and required libraries for Odoo 10

virtualenv ~/python-venv/2.7/odoo10
source ~/python-venv/2.7/odoo10/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo10/requirements.txt
deactivate

Create Python 3 Virtual Environment for Odoo 11, 12, 13, 14, 15, 16

Creating virtual environments in Python 3 is a little bit different from doing in Python2. It uses Python 3’s venv module instead of binary package as in Python2.

Please also note that all the Odoo versions from 11 can work great with Python 3.7 and Python 3.8. So, in case you don’t want to compile Python 3.6, you could use either 3.7 or 3.8, depending on your requirements.

# create virtual environment named odoo11 in ~/python-venv/3.6/odoo11
python3.6 -m venv ~/python-venv/3.6/odoo11
# activate the virtual environment
source ~/python-venv/3.6/odoo11/bin/activate
# upgrade pip for the latest version
pip install --upgrade pip
# install Odoo 11's required libraries
pip install -r ~/git/odoo11/requirements.txt
# deactivate the virtual environment
deactivate
python3.7 -m venv ~/python-venv/3.7/odoo12
source ~/python-venv/3.7/odoo12/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo12/requirements.txt
deactivate
python3.7 -m venv ~/python-venv/3.7/odoo13
source ~/python-venv/3.7/odoo13/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo13/requirements.txt
deactivate
python3.8 -m venv ~/python-venv/3.8/odoo14
source ~/python-venv/3.8/odoo14/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo14/requirements.txt
deactivate
python3.8 -m venv ~/python-venv/3.8/odoo15
source ~/python-venv/3.8/odoo15/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo15/requirements.txt
deactivate
python3.10 -m venv ~/python-venv/3.10/odoo16
source ~/python-venv/3.10/odoo16/bin/activate
pip install --upgrade pip
pip install -r ~/git/odoo16/requirements.txt
deactivate

Install & Setup Eclipse IDE with PyDev

Install Eclipse & PyDev

You can follow my post of how to install Eclipse with PyDev on Ubuntu 22.04 to complete the IDE installation.

Setup Odoo Projects and Interpreters

Now, start your Eclipse IDE. The general procedure on setup an Odoo project in Pydev includes 2 main steps:

Configure Interpreters for the Odoo projects

  1. For doing it, Click Windows -> Preference and In the Left Pane,
  2. Select PyDev > Interpreters > Python Interpreter
  3. Then on the Right side click New button then select the dropped down menu Browse for python/pypy exe, and select the python binary from the installed path which should be inside /usr/bin/. That is:
    • Python 2.7: /usr/bin/python2.7
    • Python 3.6: /usr/bin/python3.6
    • etc
  4. Input the name for the Interpreter. The best practice is to name it in form of “Python x.y – project name”. For example, when we configure interpreter for Odoo 8 project, we should name it “Python 2.7 – Odoo 8”.
  5. Click Apply and the System will automatically detect Your python version and setup paths and rest of environment variables.
  6. Click OK to Close this Windows once the Eclipse is done setting up Environment.

Create Odoo projects

  1. From the File menu, select New > PyDev Project
  2. From the PyDev Project window,
    • Input 0. Odoo8 for the box Project Name. We have 0. as the prefix for the project name as we could want these ones to be in the first rows of the project list panel.
    • Uncheck the box Use Default and browse for the directory that contains Odoo 8 source code. It is ~/git/odoo8 in our case.
    • In the Interpreter box, select the an appropriate interpreter. In this case for Odoo 8 project, we should select the “Python 2.7 – Odoo 8”.
  3. Now, click Next then click Finish.

Run & Debug Odoo from Eclipse

Now, it’s time to test your Odoo development environment by starting your Odoo in running mode and debugging mode.

  1. From the left pane, open your Odoo project to find either odoo.py (for Odoo 8 and Odoo 9) or odoo-bin
  2. Right click on it and Run As > Python Run to start Odoo for the first time. If you want to start it in debugging mode, Debug As > Python Run

Install pgAdmin 4

pgAdmin 4 is a tool that helps you manage your PostgreSQL database using web-based graphical user interface that gives more convenient than using command lines.

You can read my post on how to install pgAdmin 4 on Ubuntu 22.04 and follow the instructions there to install pgAdmin 4 Desktop for your development environment.

Please note that you may not need to install pgAdmin 4 Web. For your development environment, you’d need to install pgAdmin 4 Desktop version only.

What if you are using Window?

Odoo does not officially support running in Window environment. So, I recommend you to not use Windows as Odoo development environment too. If you can not give up your Window, I recommend you to install VirtualBox and set up a Ubuntu 22.04 Desktop virtual machine for Odoo development purpose.

Leave a Reply