Odoo 16 Installation Guide with External Custom Module for Ubuntu 22.04

This guide explains how to install Odoo 16 on Ubuntu and configure a custom module (Loan16).

Step 1: Update System

Ensure your system is up-to-date to avoid compatibility issues.

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Packages and Dependencies.

Installs a collection of development tools, Python libraries, and system dependencies needed to properly build, install, and run Odoo 16 on Ubuntu.

sudo apt install build-essential wget git python3-pip python3-dev python3-venv python3-wheel \
libfreetype6-dev libxml2-dev libzip-dev libsasl2-dev python3-setuptools libjpeg-dev zlib1g-dev \
libpq-dev libxslt1-dev libldap2-dev libtiff5-dev libopenjp2-7-dev

Step 3: Install PostgreSQL

Install the PostgreSQL database and create a dedicated Odoo user.

sudo apt install -y postgresql

Step 4: Create Odoo System User

Create a separate system user to isolate the Odoo instance.

sudo adduser --system --home=/opt/odoo16 --group odoo16

Step 5: Switch to the PostgreSQL user and create the database user for Odoo

This command creates a PostgreSQL user odoo16 with the ability to create databases, but without superuser or role-creating privileges, and prompts to set a password.

sudo -u postgres createuser --createdb --username postgres --pwprompt odoo16

Grant SUPERUSER privileges to the PostgreSQL Odoo user

sudo su postgres
psql
ALTER USER odoo16 WITH SUPERUSER;

Exit from psql and Postgres user:

\q
exit

Step 6: Install wkhtmltopdf

This tool is needed for PDF report generation in Odoo. If you're using Ubuntu, it's better to install a specific version from the official releases.

sudo apt install wkhtmltopdf

Check the wkhtmltopdf is install or not.

wkhtmltopdf --version

And the output will be as follows (If completly Install)

wkhtmltopdf 0.12.6

Step 7: Download Odoo 16

Switch to the odoo16 user, start a new shell session (/bin/bash), and set the environment as if the user had logged in normally.

sudo su - odoo16 -s /bin/bash

Clone the official Odoo 16 source code:

git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 odoo16

Step 8: Create and Activate Virtual Environment

python3 -m venv odoo16-venv
source odoo16-venv/bin/activate

Install Python dependencies:

pip install wheel
pip install numpy
pip install email-validator
pip install numpy-financial
pip install -r odoo16/requirements.txt

After Installing all requirements, exit from the odoo16-venv virtual environment:

deactivate

Step 9: Clone Loan Module

Clone your custom module Loan16 in the same directory where the Odoo source code was cloned.

cd /opt/odoo16
git clone https://github.com/vipulin/Loan16.git --depth 1

Log out of odoo16

exit

Step 10: Configure Odoo

sudo cp /opt/odoo16/odoo16/debian/odoo.conf /etc/odoo16.conf
sudo nano /etc/odoo16.conf

Paste the following content (replace your_db_password_here ):

Note: Set your_master_password for manage Database.This is the password that allows database operations

[options]
admin_passwd = your_master_password
db_host = False
db_port = False
db_user = odoo16
db_password = your_db_password_here
addons_path = /opt/odoo16/odoo16/addons,/opt/odoo16/Loan16
logfile = /var/log/odoo/odoo16.log
sudo chown odoo16: /etc/odoo16.conf
sudo chmod 640 /etc/odoo16.conf

Step 11: Create Log Directory

sudo mkdir /var/log/odoo
sudo chown odoo16:root /var/log/odoo

Step 12: Create Odoo Service

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

Paste the following:

[Unit]
Description=Odoo16
Documentation=http://www.odoo.com

[Service]
Type=simple
User=odoo16
WorkingDirectory=/opt/odoo16/odoo16
ExecStart=/opt/odoo16/odoo16-venv/bin/python3 /opt/odoo16/odoo16/odoo-bin -c /etc/odoo16.conf
Restart=always

[Install]
WantedBy=multi-user.target
sudo chmod 755 /etc/systemd/system/odoo16.service
sudo chown root: /etc/systemd/system/odoo16.service

Step 13: Start and Enable Odoo

sudo systemctl daemon-reload
sudo systemctl start odoo16.service
sudo systemctl enable odoo16.service
sudo systemctl status odoo16.service

Access Odoo

Open your browser and go to:

http://localhost:8069

Add http://localhost:8069 in Web browser page This will take you to the odoo page.Create the database with the help of Master Password.

how-to-install-odoo-16-on-ubuntu-22-04-databse-creation-image

Finally, after creating the database, you will be redirected to the Odoo login page.

how-to-install-odoo-16-on-ubuntu-22-04-odoo-login-image

Load Your Loan Module

  1. Go to Apps.
  2. Enable Developer Mode if needed.
  3. Click on the Update App List.
  4. Search for your module and install it.

    how-to-install-odoo-16-on-ubuntu-22-04-databse-creation-image

  5. If it’s not visible, check the __manifest__.py and restart Odoo.

Restart the Service (If necessary)

sudo systemctl restart odoo16.service

Check the Odoo Logs:

you can use the following command to check the logs of the Odoo platform that you have set up.

sudo tail -f /var/log/odoo/odoo16.log