How To Run Odoo 12 With Virtualenv

On Ubuntu 18.o4 or Debian 9

Hendra Juice
3 min readFeb 2, 2019

When developing Odoo 12 or another version on a local machine, I never used package installation. But, I using virtualenv to run it. Many advantages can we obtained if we develop Odoo with virtualenv. One of them is we can run various versions of Odoo on one machine simultaneously with distinguishing ports.

In this case, I use Ubuntu 18.04 and can work on Debian 9. You can try this tutorial to another operating system, but you need to search for any dependencies of Odoo on your operating system.

Odoo 12 Preparation.

  • Download Odoo 12 source code from Odoo repository on Github https://github.com/odoo/odoo or you can do git clone
  • Extract downloaded file. We only use addons/ directory, odoo/ directory, odoo-bin file, and requirements.txt file. Make sure that directory structure like the image below.
Odoo initial structure.
  • 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 same directory or different directory. In this tutorial, I use same directory as the Odoo directory.
Odoo virtualenv structure.
  • Install other dependencies for Odoo sudo apt install python3-dev libxml2-dev libxslt1-dev libldap2-dev libssl-dev libsasl2-dev
  • Activate virtualenv with . <venv-directory>/bin/activate
  • Upgrade pip withpip install --upgrade pip We need to upgrade pip module because the old pip can’t work properly with dependencies.
  • Install all Odoo dependencies in the requirements.txt with pip install -r requirements.txt

PostgreSQL Preparation.

  • Install Postgresql with sudo apt install postgresql
  • Switch to postgres account with sudo su — postgres and type psql
Postgresql preparation.
  • Create a new user on Postgresql for Odoo. In this tutorial I use odoo12 as username and odoo as a password. Type this SQL command CREATE USER odoo12 WITH CREATEDB 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.
Postgresql pg_hba config.
  • Restart your postgresql service with sudo service postgresql restart

Set Odoo Config.

Create a configuration file for Odoo named odoo.conf (or whatever you want). Fill in the file with the command below.

[options]
db_host = 127.0.0.1
db_port = 5432
db_user = odoo12
db_password = odoo
http_port = 8069
longpolling_port = 8072
addons_path = addons

You can read https://www.odoo.com/documentation/12.0/setup/deploy.html for other options of configuration. Also, you can set other 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

That’s it. Thanks for reading. If you have a question, please write in the comments section.

PS: I do not participate in the Medium Partner Program. If you like my article, this is how you can show it. Thanks.

--

--