Odoo 16 User Interface

How to Install and Deploy Odoo 16 From Source on Ubuntu Server 22.04 (Jammy Jellyfish)

This tutorial will guide you through how to install Odoo 16 on a fresh Ubuntu 22.04 Server with Python 3.10 and PostgreSQL 14.

Introduction

Odoo is a suite of business management software tools including, for example, CRM, e-commerce, billing, accounting, manufacturing, warehouse, project management, and inventory management. The Community Edition (CE) is a libre software, licensed under the GNU LGPLv3 while the Enterprise Edition (EE) has proprietary extra features and licensed under the Odoo Enterprise License.

For more information about Odoo 16 Release, please visit Odoo 16 Release Notes.

Executive Summary

After completion of Odoo 16 installation, we would expect to achieve the following:

  1. Technical Specifications:
    • Odoo 16 source code will be stored in the directory /opt/odoo/odoo16
    • Additional addons will be stored in /home/odoo16/addons_repo_name, where addons_repo_name is the name of the folder that contains additional addon modules.
    • Odoo 16 will be run under the Linux account odoo16
    • Only Linux users in the group odoo can read the Odoo 16 source code and run it.
    • Odoo 16 will run in an isolated virtual environment in the /python-venv/3.10/odoo16 with Python 3.10 (the default version comes fresh with Ubuntu 22.04)
    • The database will be PostgreSQL 14 which is the default version of PostgreSQL comes with Ubuntu 22.04
  2. Users will be able to access Odoo 16 using web browser via address http://your_ip:8089, where your_ip is the ip address of your Ubuntu 22.04 server.
  3. The users who have master password will be able to create a new datatabse or delete existing ones.
  4. The Odoo 16 will be run as a service (a.k.a daemon) and will be started automatically every time the server is started.

Step 1 – Prerequisites

Firstly, as usual, we need to update the system by running commands

sudo apt update; sudo apt dist-upgrade

Now, start to install the packages and software that are required for the later steps.

sudo apt install build-essential python3.10-dev \
python3.10-venv libsass-dev libjpeg-dev \
libjpeg8-dev libldap-dev libldap2-dev libpq-dev \
libsasl2-dev libxslt1-dev zlib1g-dev
Odoo 16 Prerequisites
Prerequisites for Odoo 16

Step 2 – Create Linux User and Group

If you have installed Odoo following my previous tutorials, you probably have the group odoo previously created. If not, you can run the following command to create the group odoo:

sudo addgroup odoo

Now, run the following command to create a system user account named odoo16 and add it to the group odoo mentioned above:

sudo adduser odoo16 --system \
--home=/home/odoo16 --disabled-login \
--disabled-password --ingroup odoo

Step 3 – Prepare PostgreSQL

Odoo is designed to work with all the stable and current versions of PostgreSQL. In this tutorial, for your convenient, we will use the version that comes fresh with Ubuntu 22.04 which is PostgreSQL 14. In case you want to test it on mutiple versions of PostgreSQL, please follow my instructions on installing multiple versions of PostgreSQL instead.

Install PostgreSQL 14

sudo apt install postgresql postgresql-contrib
Install PostgreSQL 14
Install PostgreSQL

Create Role

We are going to create a role that has the same name as the unix account’s so that the account can use the role to authenticate and login PostgreSQL uing the method ident (without apassword). In this case, the role name will be odoo16.

sudo -u postgres createuser --interactive

The system will ask you to input for the role name, superuser access, etc. Please input as below:

Create Postgres Role odoo16
Create Postgres Role odoo16

Please note that you would need to specify database port if your PostgreSQL cluster was not running on the default port 5432. For example, if you changed the port of your database to 5433, the above command would become:

sudo -u postgres createuser --interactive -p 5433

Step 4 – Create Python Virtual Environment

Create a directory for the virtual environment to run Odoo 16

sudo mkdir -p /python-venv/3.10/odoo16

Grant appropriate access rights by changing the owner of the directory to odoo16 to prevent others to modify it.

sudo chown -hR odoo16:root /python-venv/3.10/odoo16

Switch to the account odoo16 with bash support

sudo su - odoo16 -s /bin/bash

Create a Python 3.0 virtual environment and name it odoo16

python3.10 -m venv /python-venv/3.10/odoo16

Activate the virtual environment for the current account (i.e. odoo16)

source /python-venv/3.10/odoo16/bin/activate

Upgrade pip for the latest version

pip install --upgrade pip

Deactivate the environment

deactivate

Exit the account odoo16 and get back to the previous user account

exit

Step 5 – Download and Install Odoo 16

Download Odoo 16 From GitHub

Create the directory /opt/odoo/odoo16 to store Odoo 16 source code

sudo mkdir -p /opt/odoo/odoo16

Download Odoo 16 source code from GitHub

sudo git clone -b 16.0 https://github.com/odoo/odoo.git /opt/odoo/odoo16

If you prefer to download it over SSH for better performance and security, you may follow my tutorial on how to clone github repo over SSH. Then, the command to download Odoo 16 will be:

sudo git clone -b 16.0 git@github.com:odoo/odoo.git /opt/odoo/odoo16 

Now, grant group odoo access rights to the directory so that the account odoo16 will be able to access the Odoo 16 source code.

sudo chown -hR root:odoo /opt/odoo/odoo16

Create Custom Addons Directory

You may need custom addons in addition to the standard Odoo addons for your deployment. Run the following command to create the parent forder to store your custom addons later

sudo mkdir -p /home/odoo16/addons_repo_name

Now, copy your custom addons / modules and put them into the /home/odoo16/addons_repo_name

Please remember to change its owner for access control:

sudo chown -hR odoo16:root /home/odoo16/addons_repo_name

Install Odoo 16’s requirements

Switch to odoo16 account and activate the virtual environment

# switch account 
sudo su - odoo16 -s /bin/bash 
# activate the environment 
source /python-venv/3.10/odoo16/bin/activate 

Now, install the required libraries specified in the /opt/odoo/odoo16/requirements.txt:

pip install -r /opt/odoo/odoo16/requirements.txt

For some reasons, not all of required libraries are listed in the requirements.txt. Here is an example for the library pylibdmtx: https://github.com/odoo/odoo/commit/3ebe118. So, we need to install them manuall.

Now, install the library pylibdmtx that help Odoo 16 be able to print Data Matrix barcodes:

pip install pylibdmtx

Install wkhtmltopdf

Odoo generates PDF from HTML, that’s why we need the wkhtmltopdf.

Download wkhtmltopdf:

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb

Install wkhtmltopdf:

sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
# force install dependencies
sudo apt -f install -y

Start Odoo 16

Now, everything is almost done and we can test the Odoo 16 by running the command:

/opt/odoo/odoo16/odoo-bin

You will see something like below as the result

Start Odoo 16 from command line on Ubuntu 22.04
Start Odoo 16 from command line on Ubuntu 22.04

Now, open your desired web browser and input the address

http://your_ip:8069

Then if you find your Odoo 16 is up and running with the database creator/selector UI as below, congrats!

Odoo 16 Database Creator User Interface
Odoo 16 Database Creator/Selector UI

Now, hit Ctrl+C twice to stop the Odoo 16 and run the command below to exit the account odoo16 and get back to the previous one:

exit

Step 7 – Run Odoo 16 as a service / daemon

This section will guide you on how to create a startup service for your newly installed Odoo 16 so that your Odoo 16 will be running as a service and started every time the server is started.

Create Odoo 16 Configuration File

Odoo 16 configuration file is a file that stores configuration directives that let Odoo 16 know how to run (e.g. addons path, database port, etc).

In this section, I will create a configuration file named odoo16.conf and store it in /home/odoo16. I will use the text editor nano to create the file as below:

sudo nano /home/odoo16/odoo16.conf

Now, copy and paste the following in your nano text editor UI:

[options]
addons_path = /opt/odoo/odoo16/odoo/addons,/opt/odoo/odoo16/addons,/home/odoo16/addons_repo_name
admin_passwd = admin
csv_internal_sep = ,
data_dir = /home/odoo16/.local/share/Odoo
db_host = False
db_maxconn = 64
db_name = False
db_password = False
db_port = False
db_sslmode = prefer
db_template = template0
db_user = False
dbfilter =
demo = {}
email_from = False
from_filter = False
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb
gevent_port = 8072
http_enable = True
http_interface =
http_port = 8069
import_partial =
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 120
limit_time_real_cron = -1
list_db = True
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = info
logfile =
max_cron_threads = 2
osv_memory_age_limit = False
osv_memory_count_limit = 0
pg_path =
pidfile =
proxy_mode = False
reportgz = False
screencasts =
screenshots = /tmp/odoo_tests
server_wide_modules = base,web
smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_ssl_certificate_filename = False
smtp_ssl_private_key_filename = False
smtp_user = False
syslog = False
test_enable = False
test_file =
test_tags = None
transient_age_limit = 1.0
translate_modules = ['all']
unaccent = False
upgrade_path =
websocket_keep_alive_timeout = 600
websocket_rate_limit_burst = 10
websocket_rate_limit_delay = 0.2
without_demo = False
workers = 0
x_sendfile = False

Please note that the master password to secure your instance is controlled by the directive admin_passwd in the configuration file. You should change it to a strong one. You can also start tuning the instance by modifying other directives. After everything is fine for you, you can save the file and exit by hitting Ctrl+X and input y then press Enter.

To allow the account odoo16 to access the configration file while preventing others from to do that, we need to change the file owner by running the command below:

sudo chown odoo16:root /home/odoo16/odoo16.conf

Create Odoo 16 Unit file

In this tutorial, I’m using the text editor nano to create the unit file for Odoo 16.

sudo nano /lib/systemd/system/odoo16.service

Then, copy and pasted the following in your nano editor UI

[Unit]
Description=Odoo16
After=network.target postgresql.service

[Service]
Type=simple
PermissionsStartOnly=true
User=odoo16
Group=odoo
SyslogIdentifier=odoo16
PIDFile=/run/odoo16/odoo16.pid
ExecStartPre=/usr/bin/install -d -m755 -o odoo16 -g odoo /run/odoo16
ExecStart=/python-venv/3.10/odoo16/bin/python /opt/odoo/odoo16/odoo-bin --pid=/run/odoo16/odoo16.pid
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
Alias=odoo16.service
WantedBy=multi-user.target

Now, save the file and exit by hitting Ctrl+X then input y and press Enter.

Run the following command to notify systemd that a new unit file exists

sudo systemctl daemon-reload

Now, enable the service and ask it to run on boot

sudo systemctl enable --now odoo16

Now, start your Odoo 16 using systemd

sudo systemctl start odoo16

To stop it, just run:

sudo systemctl stop odoo16

Conclusions

You have just gone through the steps to install Odoo 16 on Ubuntu server that meets the expectation stated in the executive summary.

By the way, you may want to check out other posts of mine for:

If you are an Odoo developer, you may want to check out my post on How to setup Odoo development environment on Ubuntu 22.04 Desktop.

6 thoughts on “How to Install and Deploy Odoo 16 From Source on Ubuntu Server 22.04 (Jammy Jellyfish)”

  1. Thank you, it was very helpful, is there a way to do a tutorial using echo using nightly builds?

    In that way it can be simply updated using apt-get update command.

    Appreciate your efforts sir.

  2. Hello,
    me again (I already wrote on Odoo8 blog).
    Cause user odoo16 you can not
    sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
    Do I have to deactivate and exit odoo16 before and go as normal user?

    1. sudo dpkg as normal user seems to be the right way, however below error constist and I can not reach Odoo at IP:8069

  3. I went back to the normal user (as test) and did the sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb and following steps.
    And later when first time starting (in the (re-) activated enviroment) as written with /opt/odoo/odoo16/odoo-bin
    I get an error:
    2023-08-12 15:33:52,717 49704 WARNING ? py.warnings: /python-venv/3.10/odoo16/lib/python3.10/site-packages/pylibdmtx/wrapper.py:8: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

Leave a Reply