Run Odoo 12 With Virtualenv on Ubuntu & Debian

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.

SS Odoo Venv 1

  • 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.

SS Odoo Venv 2

  • Install other dependencies for Odoo sudo apt install python3-dev libxml2-dev libxslt1-dev libldap2-dev libssl-dev libsasl2-dev libpq-dev
  • Activate virtualenv with . <venv-directory>/bin/activate
  • Upgrade pip with pip 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

SS Odoo Venv 3

  • 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 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.

SS Odoo Venv 4

  • 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

SS Odoo Venv 5

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.

Read: Install Odoo 12 and Wkhtmltopdf on Ubuntu 18.04 or Debian 9

Comments

2 thoughts on “Run Odoo 12 With Virtualenv on Ubuntu & Debian”

  1. Pingback: Install Odoo 12 and Wkhtmltopdf on Ubuntu 18.04 or Debian 9 - Cak Juice

  2. Pingback: Docker-Compose-Odoo13 | Poris Indah

Comments are closed.