By: Arif Khan
Hi there, today we will talk about ODOO.
Introduction to Odoo:
If you are willing to build a highly integrated ERP solution to meet the requirements of today’s business, then the choice is Odoo. I personally like it the most, I suggest you to give it a try.
Why Odoo?
Because Odoo is open source suite covering all needs of today’s business world, if you have at least mid-level knowledge of Python, XML, ORM and if you are willing to learn, then you could learn more and more while doing development work in Odoo. You could know everything about Odoo by visiting their official site https://www.odoo.com.
I will tell you about its installation and configuration step by step in Ubuntu environment. So, without wasting much time let’s start now.
Step A. Update Ubuntu 20.04:
Login to your Ubuntu system and issue below command to update.
sudo apt-get update
sudo apt-get upgrade
Setp B. Secure your System:
To protect your system from SSH attacks, you need to install fail2ban, to do this issue below command.
Sudo apt-get install openssh-server fail2ban
Step C. OS user creation for Odoo operations:
You need to create a new system user and grant that user all Odoo related files and directories.
sudo adduser --system --home=/opt/odoo --roup odoo
Step D. Time to install all dependencies. (First install python3-pip and then rest of the packages below are the commands execute them in your system):
sudo apt-get install -- python3-pip
Below are Important packages/libraries must be installed before installation of requirements.txt
sudo apt-get install python-dev python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev
All above packages/libraries should install carefully. If you find any error during installation then you have to re-execute above commands. So that, they finish their installation successfully, you need to install some web dependencies as well.
sudo apt-get install –y npm
sudo ln –s /usr/bin/jodejs /usr/bin/node
sudo npm install –g less less-plugin-clean-css
sudo apt-get install –y node-less
Step E. Postgresql Installation:
From Debian repository, you have to install Postgresql. Keep this in mind that Odoo uses Postgresql as its backend database. You have to install and configure it properly and carefully.
sudo apt-get install postgresql
After Postgresql installation you will have to create Database User to manage Odoo Databases. So, initially you need to switch user to Postgres by issuing below command.
sudo su – postgres
Step F. Creation of DB user for Odoo:
After switching into postgres, you have to issue below command to create odoo user the username of your choice, but recommend you to create it as odoo14, it will easier to remember, when you execute below command, it will ask you for password, supply it a password of your choice, but don’t forget that password because you have to write that password in configuration file. So, be careful with that.
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo14
Step G. Switch into SQL Mode:
Now go into SQL MODE by issuing command psql and alter the newly created user to assign it SUPERUSER Privileges. Below will do that for you and will print success message.
psql
ALTER USER odoo14 WITH SUPERUSER;
To exit from SQL MODE issue.
\q
Exit
Now its time to get Git software, it will clone the odoo community source files into our system from Odoo Git repository. If you already got Git installed in your system then skip, otherwise issue below command.
sudo apt-get install git
Step H. Change he system user:
Change the system user as odoo, if you remember, you already created the odoo system user earlier in this blog.
sudo su --odoo -- /bin/bash
Step I. Start cloning:
Now start cloning the Odoo repository and its corresponding branch.
git clone https://github.com/odoo/odoo --depth 1 --branch 14.0 --ingle-branch
All source files will be cloned to the home directory of user odoo, home directory is also created earlier in the blog. Exit from odoo directory after successful cloning of odoo into your system.
exit
Step J. Installation of Python packages dependencies:
You are now going to install all python package dependencies in your system, Odoo will use those packages. Execute following command.
sudo pip3 install -r /opt/odoo/odoo/requirements.txt
Ensure that all packages are installed successfully, if you find any error during installation, it means that above under yellow highlighted text packages did not installed properly and you have to re-execute under yellow highlighted text command again to install them properly, and after that re-run requirements installation. Hopefully it will be installed properly then.
Step K. Installation of wkhtmltopdf:
Also note that Odoo uses wkhtmltopdf for report printing, use below command to install it.
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo dpkg -I wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install -f
As you cloned the Odoo source from Git, now its time inform Odoo some information it needs to start. For this you need to copy the default config file which contains standard information from opt to etc by using below command. After copying you have to edit it with below second command.
Step L. Copying Odoo Config File:
sudo cp /opt/odoo/odoo/debian/odoo.conf /etc/odoo.conf
Step M. Creating Odoo Log Dir:
sudo mkdir /var/log/odoo
Step N. Editing Odoo Conf File:
sudo nano /etc/odoo.conf
The odoo.conf will look like below file. Although I have changed it and you have to change your same as I did:
[option]
;This is the password that allows database operations:
admin_passwd = admin
db_host =localhost
db_port =5432
db_user =odoo14
db_password = (your db password)
addons_path = /opt/odoo/odoo/addons
logfile = /var/log/odoo/odoo.log
To exit nano press Ctrl+X it will ask to save the changes hit ‘Y’ and hit enter.
Step O. Issuing grants:
Now grant access rights to above created conf file by issuing following commands.
sudo chown odoo:root /var/log/odoo
sudo chown odoo: /etc/odoo.conf
sudo chmod 640 /etc/odoo.conf
You are just about to finalize your installation of Odoo, some last steps more to go.
Step P. Creating Odoo Service:
Now you need to create a new file and name it as ‘odoo.service’ by executing below command.
sudo nano /etc/systemd/system/odoo.service
Edit it as I edited mine.
[Unit]
Description = OdooSrv
Documentation = https://www.scriptsview.com
[Service]
Type = simple
User = odoo
ExecStart = /opt/odoo/odoo/odoo-bin -c /itc/odoo.conf
[Install]
WantedBy = default.target
To exit nano press Ctrl+X it will ask to save the changes hit ‘Y’ and hit enter.
Give it permissions as you did above.
sudo chmod 755 /etc/systemd/system/odoo.service
sudo chown root: /etc/systemd/system/odoo.service
You are about to launch your rocket.
Step Q . Starting Odoo Service:
Let’s start the newly created odoo service and its status using below command.
sudo systemctl start odoo.service
sudo systemctl status odoo.service
If it is started successfully then it will give you the status of service, otherwise it will give you the error. Hopefully it won’t give you errors if you followed my instructions as I said Inshallah.
To check the service log type.
sudo tail -f /var/log/odoo/odoo.log
If Odoo is working fine and you want the service to start at the time of system startup automatically then issue below command.
sudo systemctl enable odoo.service
Go to browser and in the address bar type localhost:8069 , you will see Odoo welcome screen .
Hope that this blog will enhance your knowledge and experience. In upcoming articles I will tell you how to configure its development environment to start development in Odoo.
Looking forward to hear from you in comment section. Your feedbacks are important to me.