How to Setup Odoo 12 in Ubuntu 18.04 for Development
By: Gusti Tammam
Tags: Odoo Development, Erp Software, Odoo 12, Ubuntu, Odoo

Screenshot: Odoo 12.0 Enterprise Edition

Odoo is an all-in-one business software including CRM, website/e-commerce, billing, accounting, manufacturing, warehouse — and project management, and inventory. The Community version is the open-source version, while the Enterprise version supplements the Community edition with proprietary features and services.

— Wikipedia

Here I will show you step by step how am I setup Odoo 12.0 in my Ubuntu 18.04 x64 for development. We need to clone Odoo source code from GitHub, but before that, we need to prepare the dependencies in our operating system. So, let’s get started!

Update the Repository and Upgrade the System

Run this command below in terminal, if password prompted please input your user’s password.

$ sudo apt-get update

$ sudo apt-get upgrade -y

Install PostgreSQL Server

Odoo uses PostgreSQL as a database server, so we will install it first with the command below.

$ sudo apt-get install postgresql -y

Create PostgreSQL Server User

Then create a database user to use in Odoo. Here I will create a new PostgreSQL user with the username is odoo12.

$ sudo su - postgres -c "createuser -sP odoo12"

If prompted password, please input your database user’s password.

Install Dependency

The command below will let you install libpng12–0.



$ sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb

$ sudo rm -rf libpng12* $ sudo wget http://security.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb $ sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb$ sudo rm -rf libpng12*

The command below will let you install python3, pip3, and other required packages.

$ sudo apt-get install python3 python3-pip git gdebi-core -y

$ sudo apt-get install node-clean-css -y

$ sudo apt-get install node-less -y

$ sudo apt-get install libxml2-dev libxslt1-dev zlib1g-dev -y

$ sudo apt-get install libsasl2-dev libldap2-dev libssl-dev -y

$ sudo apt-get install openssl -y

Also, we need to install wkhtmltopdf because Odoo will use it to generate the PDF report.



$ sudo gdebi --n wkhtmltox-0.12.1_linux-trusty-amd64.deb

$ sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin

$ sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin

$ sudo rm -rf wkhtml* $ sudo wget https://downloads.wkhtmltopdf.org/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb $ sudo gdebi --n wkhtmltox-0.12.1_linux-trusty-amd64.deb$ sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin$ sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin$ sudo rm -rf wkhtml*

Then install node stuff with this command below.

$ sudo apt-get install nodejs npm -y

$ sudo npm install -g less

$ sudo npm install -g less-plugin-clean-css

Clone Odoo 12.0 Source from GitHub

Before I clone Odoo 12.0 source code, usually I set up the development directory structure. It’s up to you to clone it anywhere but here is my directory structure.

|- /home/tammam/

|-- Development/

|--- Odoo/

|---- 8.0/

|---- 9.0/

|---- 10.0/

|---- 11.0/

|---- 12.0/ <-- I will clone the Odoo 12.0 here.

|---- 13.0/

So I clone Odoo 12.0 source in /home/tammam/Development/Odoo/12.0/ with this command below.



$ git clone --depth 1 --branch 12.0 $ cd /home/tammam/Development/Odoo/12.0/$ git clone --depth 1 --branch 12.0 https://github.com/odoo/odoo.git odoo

Setup Project Directory: Virtual Environment

Before run Odoo, I prepare the project directory. I create a virtual environment for every project directory, so Odoo runs in different environment per project. This is my directory structure.

|- /home/tammam/

|-- Development/

|--- Odoo/

|---- 8.0/

|---- 9.0/

|---- 10.0/

|---- 11.0/

|---- 12.0/

|----- odoo/ <-- This is odoo source directory I cloned before.

|----- Project/

|------ first_project/ <-- This is my project directory.

|---- 13.0/

Let’s create the project directory and virtual environment. But first, we will install the virtualenv.

$ sudo pip3 install virtualenv

$ mkdir -p /home/tammam/Development/Odoo/12.0/Project/first_project

$ cd /home/tammam/Development/Odoo/12.0/Project/first_project

$ virtualenv -p python3 venv

The new folder named venv will be created inside the first_project directory. Now let’s activate it with this command below.

$ source venv/bin/activate

You’ll see the virtual environment name appear just before the dollar sign ($) and ready to use.

(venv) $

Install Odoo Requirements

While the virtual environment is active, let’s run this command below to install the requirements inside the currently active virtual environment.

(venv) $ pip3 install -r /home/tammam/Development/Odoo/12.0/requirements.txt (venv) $ pip3 install acme-tiny IPy numpy python-barcode num2words ofxparse

Setup Addons Directory

Before run Odoo, please create a directory to store custom addons. I create directory named addons inside the project directory.

|- ../

|-- first_project/

|--- addons/ <-- My custom addons directory.

|--- venv/

Setup Configuration File

We need to tell Odoo where is our custom addons directory, so let’s write the configuration file. The configuration file not only contains custom addons directories path, please check this link for more details. But we won’t use all options of the config file, in this article I only use the basic options to run Odoo instantly.

First I create a directory named config to store config files inside the project directory.

(venv) $ mkdir config

(venv) $ touch odoo.conf

Now the project directory looks like below.

|- ../

|-- first_project/

|--- addons/

|--- config/

|---- odoo.conf <-- The config file.

|--- venv/

Copy and paste this configuration to the config file.

[options]

xmlrpc_port = 8069

db_host = localhost

db_port = 5432

db_user = odoo12

db_password = secret

addons_path = /home/tammam/Development/Odoo/12.0/odoo/addons, /home/tammam/Development/Odoo/12.0/Project/first_project/addons

Explanation: