Odoo is a suite of business management software tools including, for example, CRM, e-commerce, billing, accounting, manufacturing, warehouse, project management, and inventory management.
In this tutorial we will demonstrate how to install Odoo 12 in a virtual environment using Ubuntu 20.04.
Installing Odoo 12 on Ubuntu 20 have a lot of challenges because of compatibility issues. Some of the Python modules used on Odoo 12 is outdated that makes it challenging to install it on Ubuntu 20.04.
Let us start with the installation.
1. Updating the system
sudo apt update -y && apt upgrade -y
2. Installing Python Dependencies
Since Odoo is built with Python we need to install all the Odoo dependencies on Python.
sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libjpeg-dev zlib1g-dev libldap2-dev libsasl2-dev python3-setuptools node-less node-clean-css
3. Installing the Database
Odoo uses PostgreSQL as a database. To install PostgresSQL server on Ubuntu run the follwing command.
sudo apt install postgresql -y
4. Creating System and PostgreSQL user
First we need to create a system user named odoo12 and set the home directory to /opt/odoo12. To do that we need to run the following command.
sudo useradd -m -d /opt/odoo12 -U -r -s /bin/bash odoo12
After creating the system user, we need to create a PostgreSQL user and we will named it also as odoo12.
sudo su - postgres -c "createuser -s odoo12"
5. Installing wkhtmltopdf
Wkhtmltopdf is an open source command line tool that render HTML into PDF format using the Qt WebKit rendering engine. This tool is necessary for printing PDF reports in Odoo.
The version of wkhtmltopdf that we are going to install is version 0.12.5 since our server is Ubuntu 20.04.
First we need to download wkhtmltopdf 0.12.5.
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
Then make it executable.
chmod +x wkhtmltox_0.12.5-1.bionic_amd64.deb
After making the file executable, install it.
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb
6. Odoo 12 installation and configuration
First we need to switch to user odoo12.
su - odoo12
Cloning Odoo12 repository from Github.
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo
Create a virtual environment for your Odoo application.
cd /opt/odoo12
python3 -m venv myodoo-venv
Activate the virtual environment
source myodoo-venv/bin/activate
After activating the virtual environment, we will install the Odoo dependencies. The Python modules dependencies needed to run Odoo is set in the requirements.txt file. But before we proceed we need to change the Psycopg2 directive set on requirements.txt to Psycopg2-binary==2.8.6.
Note: Changing the Psycopg2 directive in the requirement.txt file is important because the outdated version in Odoo 12 will not work on Ubuntu 20.04.
Let us edit requirements.txt and add psycopg2-binary==2.8.6
nano odoo/requirements.txt
Put comment on psycopg2==2.8.3 and psycopg2==2.7.3.1 and add psycopg2-binary==2.8.6
Babel==2.3.4
chardet==3.0.4
decorator==4.0.10
docutils==0.12
ebaysdk==2.1.5
gevent==1.1.2 ; sys_platform != 'win32' and python_version < '3.7'
gevent==1.5.0 ; python_version >= '3.7'
greenlet==0.4.10 ; python_version < '3.7'
greenlet==0.4.14 ; python_version >= '3.7'
html2text==2016.9.19
Jinja2==2.10.1
libsass==0.12.3
lxml==3.7.1 ; sys_platform != 'win32' and python_version < '3.7'
lxml==4.2.3 ; sys_platform != 'win32' and python_version >= '3.7'
lxml ; sys_platform == 'win32'
Mako==1.0.4
MarkupSafe==0.23
mock==2.0.0
num2words==0.5.6
ofxparse==0.16
passlib==1.6.5
Pillow==4.0.0 ; python_version < '3.7'
Pillow==6.1.0 ; python_version >= '3.7'
psutil==4.3.1; sys_platform != 'win32'
psutil==5.6.3; sys_platform == 'win32'
psycopg2-binary==2.8.6
#psycopg2==2.7.3.1; sys_platform != 'win32' and python_version < '3.8'
#psycopg2==2.8.3; sys_platform == 'win32' or python_version >= '3.8'
pydot==1.2.3
pyldap==2.4.28; sys_platform != 'win32'
pyparsing==2.1.10
PyPDF2==1.26.0
pyserial==3.1.1
python-dateutil==2.5.3
pytz==2016.7
pyusb==1.0.0
qrcode==5.3
reportlab==3.3.0
requests==2.20.0
suds-jurko==0.6
vatnumber==1.2
vobject==0.9.3
Werkzeug==0.11.15 ; sys_platform != 'win32'
Werkzeug==0.16.0 ; sys_platform == 'win32'
XlsxWriter==0.9.3
xlwt==1.3.*
xlrd==1.0.0
pypiwin32 ; sys_platform == 'win32'
The above should be the content of your requirements.txt. Let us save our requirements.txt and close the file.
Let us proceed with the installation of all required Python modules with pip3.
(myodoo-venv) pip3 install wheel
(myodoo-venv) pip3 install Pillow
(myodoo-venv) pip3 install -r odoo/requirements.txt
After installing the the Python modules we need to deactivate the virtual environment.
(myodoo-venv) $ deactivate
Now we need to create an Addons directory for third party addons.
mkdir /opt/odoo12/custom-addons
Let’s exit to odoo12 user and go back to our sudo user.
exit
Now we need to create the Odoo configuration file.
sudo nano /etc/odoo12.conf
Insert the content below:
[options]
; This is the password that allows database operations:
admin_passwd = admin_password
db_host = False
db_port = False
db_user = odoo12
db_password = False
xmlrpc_port = 8069
logfile = /var/log/odoo12/odoo.log
addons_path = /opt/odoo12/odoo/addons,/opt/odoo12/custom-addons
Please make sure to change the “admin_password” to your preferred password, then save and close the file.
Next, we need to create a log directory.
sudo mkdir /var/log/odoo12
Set the ownership to odoo12.
sudo chown odoo12:root /var/log/odoo12
7. Create a Odoo 12 Systemd Service
To manage our Odoo 12 we need to create a systemd file.
sudo nano /etc/systemd/system/odoo12.service
Add or insert the following.
[Unit]
Description=Odoo12
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo12
Group=odoo12
ExecStart=/opt/odoo12/myodoo-venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
Save and close the file and reload the systemd daemon to apply the changes:
sudo systemctl daemon-reload
Start and enable the Odoo12 service.
sudo systemctl enable --now odoo12
Check the status of the Odoo12 service.
systemctl status odoo12
Congratulations, you can now access your Odoo 12 application at http://ipaddress:8069
Conclusion
In this tutorial you have learned how to install Odoo 12 on Ubuntu 20.04.
If you have questions, feel free to leave a comment and we will try to answer it.
Thank you and hope you enjoy our tutorial ?