Running Odoo 13 with Virtualenv on Ubuntu 20.04 is a little different from Ubuntu 18.04. For information, Ubuntu 20.04 using Python 3.8. Running Odoo on a local machine with virtualenv has many advantages.
Let’s check this out how to run Odoo 13 with virtualenv on Ubuntu 20.04.
Postgresql Preparation
- Install Postgresql with
sudo apt install postgresql
- Switch to postgres account with
sudo su - postgres
and typepsql
- Create a new user on Postgresql for Odoo. In this tutorial I use odoo13 as username and odoo as a password. Type this SQL command
CREATE USER odoo13 WITH SUPERUSER ENCRYPTED PASSWORD 'odoo';
- Quit from postgres account then configure postgresql pg_hba file. Open pg_hba with
sudo nano /etc/postgresql/<postgresql-version>/main/pg_hba.conf
add a command for Odoo custom config like image below.
- Restart your postgresql service with
sudo service postgresql restart
Odoo Preparation
- Download Odoo 13 source code from Odoo repository on Github https://github.com/odoo/odoo or you can do
git clone
- Extract the downloaded file. We only use
addons/
directory,odoo/
directory,odoo-bin
file, andrequirements.txt
file. Make sure the directory structure like the image below.
- Install python3 pip and virtualenv with
sudo apt install python3-pip python3-venv
- Create virtualenv with
python3 -m venv <venv-directory>
- You can create virtualenv on the same directory or different directory. In this tutorial, I use the same directory as the Odoo directory.
- Install other dependencies for Odoo
sudo apt install python3-dev libxml2-dev libxslt1-dev libldap2-dev libssl-dev libsasl2-dev libpq-dev libjpeg8-dev
- Activate virtualenv with
source <venv-directory>/bin/activate
- We need to upgrade the pip module because the old pip usually can’t work properly with dependencies. Upgrade pip with
pip install -U pip
- Install all Odoo dependencies in the
requirements.txt
withpip install -r requirements.txt
Set Odoo config
Create a configuration file for Odoo named odoo.conf
(or whatever you want). Fill in the file with the command below.
You can read https://www.odoo.com/documentation/13.0/setup/deploy.html for other options of configuration. Also, you can set another port for http_port and longpolling_port.
And you just need activating virtualenv then run ./odoo-bin -c odoo.conf
Open your browser and type localhost:8069
or ip_address:port
.