Friday, 5 June 2020

How to install Odoo 12 on Ubuntu 18.04



Update and upgrade
Before we get into the installation process, you should definitely update and upgrade Ubuntu. 
Open a terminal window and issue the commands:
sudo apt-get update
sudo apt-get upgrade
Note: Should the kernel upgrade, you'll have to reboot the server. 
Because of this, make sure you run the update/upgrade commands at a time when a reboot is acceptable.
Dependency installation
There are a few dependencies to install. The good news is that they can all be installed with a single command:
sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less postgresql
Creating the necessary users
The first step in the installation is to create a user named odoo. To do this, issue the following command:
sudo useradd -m -d /opt/odoo -U -r -s /bin/bash odoo
With the standard user created, we also need to create a PostgreSQL user of the same name. Issue the command:
sudo su - postgres -c "createuser -s odoo"
Installing ODOO
Now we're ready to install ODOO. First change to the odoo user with the command:
sudo su - odoo
Now we're going to clone the 12.0 branch from git (into the /opt directory) with the command:
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo/odoo12
Issue the command cd /opt/odoo, and then create a new virtual environment with the command:
python3 -m venv odoo12-venv
Active the environment with the command:
source odoo12-venv/bin/activate
Install the necessary Python modules, via pip3, with the commands:
pip3 install wheel
pip3 install -r odoo12/requirements.txt
The second of the two above commands takes roughly 5-10 minutes. Once it completes, deactivate the environment, and exit back to the standard user with the commands:
deactivate
exit
You need to install the wkhtml2pdf library for the system to generate pdf files:
sudo wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.1.3-1~bionic_amd64.deb
sudo apt-get install -f
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
In order to make use of the powerful add-on system, you must create a new directory. Do this (and give it the necessary ownership) with the commands:
sudo mkdir /opt/odoo/custom-addons
sudo chown odoo: /opt/odoo/custom-addons

You may copy your custom addons developed by you or got from a thrid party to this folder and add this path in configuration file later.
Create a new configuration file for ODOO with the command:
sudo cp /opt/odoo/odoo12/debian/odoo.conf /etc/odoo12.conf
Open that file
sudo nano /etc/odoo12.conf

Copy & paste the following config options in that file : [select the text and ctrl+c for copy and right click on the terminal for paste]
[options]
; This is the password that allows database operations:
admin_passwd = Password
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo12/addons
Where Password is a unique (and strong) password.
Save and close that file. 
Ctrl + x for closing the file and press y for confirmation
In order for ODOO to run as a service, you must create a systemd file. Issue the command:
sudo nano /etc/systemd/system/odoo12.service
The contents of that file must be:
[Unit]
Description=Odoo12
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target
Reload the systemd daemon, and then start ODOO with the commands:
sudo systemctl daemon-reload
sudo systemctl start odoo12
Enable ODOO start at boot with the command:
sudo systemctl enable odoo12
Point a browser to http://localhost:8069, and you will be presented with the database creation page

How to install Odoo 12 on Ubuntu 18.04

Update and upgrade Before we get into the installation process, you should definitely update and  upgrade Ubuntu.  Open a ...