Install Odoo12 On Ubuntu20.04

💡 This post is insightful for the following scenarios.

  • Odoo Installation

Background

To avoid Odoo corrupting my noble macOS 🤫, I’ve decided to install Odoo on Ubuntu.

Step

0. Preparation

Of course, you need to have Ubuntu which is 20.04 (X86) and it need to be able to connect the Internet.

The system I use is build from my previous post.

1. Install Git

1
2
sudo apt-get update
sudo apt-get install -y git

2. Install PostgreSQL

1
2
3
4
5
# the version I downloaded is postgresql12
sudo apt-get install -y postgresql

# we can use the following command to check postgresql version
psql --version

3. Create PostgreSQL user and database

1
2
3
4
5
6
7
8
9
10
11
# start postgresql service
sudo service postgresql start

# create postgresql user and database
sudo -u postgres -i

# type your password and remember it
createuser -P --superuser odoo

# may cause error
createdb odoo -U odoo -W

You may meet some error when you run the last command

1
FATAL:  Peer authentication failed for user "odoo"

If so, you should change your pg_hba.conf configuration

1
vim /etc/postgresql/12/main/pg_hba.conf

1
2
3
4
5
6
# then restare postgresql service
sudo service postgresql restart

# complete commands that were not fully executed before
sudo -u postgres -i
createdb odoo -U odoo -W

4. Install curl

1
sudo apt-get install curl

5. Install node.js and less

Install nodejs version manager

1
curl -L http://git.io/n-install | bash  

Reopen your terminal and check current version

Install less

1
npm install -g less

6. Clone Odoo source code

1
git clone https://github.com/odoo/odoo.git -b 12.0 --depth=1 ./odoo12

7. Install specific python version (optional)

Choose one of these two options that you like

7.1 Install pyenv to manage python version

1
2
3
4
5
6
7
8
# install pyenv
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

# install python dependencies (optional, mostly depend on your perrsonal situation)
sudo apt-get update && apt-get install -y default-libmysqlclient-dev build-essential git gcc make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev libldap2-dev libsasl2-dev

# install python 3.8
pyenv install 3.8 && pyenv global 3.8

7.2 Use original python3 from ubunutu

Here I use original python 3.8 from ubunutu (which not include pip3)

8. Install odoo dependencies by pip3

1
2
3
4
5
6
7
8
# install pip3
sudo apt-get install python3-pip

# enter odoo folder (which is odoo12 as I wrote above)
cd odoo12

# install odoo dependencies provided by odoo
pip3 install -r requirements.txt

You may meet some difficulties when you want to install the following package:

8.1 lxml: install it without specific version.

You need to modify requirements.txt

8.2 Pillow: install it without specific version

You need to modify requirements.txt

8.3 psycopg2: lack of specific library

You need to install some package. You don’t need to modify requirements.txt.

1
sudo apt-get install libpq-dev

8.4 pyldap: lack of specific library

You need to install some package. You don’t need to modify requirements.txt.

1
2
# If you follow the approach "Install pyenv to manage python version" in this article, you may not meet this error because you already install these libraries before
sudo apt-get install libldap2-dev libsasl2-dev

9. Start odoo

1
2
3
4
5
6
7
# enter odoo folder (which is odoo12 as I wrote above)
cd odoo12

# install odoo dependencies provided by odoo
./odoo-bin

# press ctrl+c to quit

Then turn on your browser and go to this url -> localhost:8069, and you may find some error now.

Front end:

Back end:

This is because you have not configure your odoo.

1
2
3
4
# run this command and then exit it 

# this command mean save the configuration in the user folder
./odoo-bin -s

You can see there is odoo configuration now.

1
2
# modify your .odoorc configuration file
vim /home/simon/.odoorc

You should update these three configuration: “db_name”, “db_user”, “db_password”.

Start the odoo again, and it show the error message like these.

1
2
# well let's initialize our database as there is nothing in the database
./odoo-bin -i base

And this time everything is fine.

10. Enjoy your odoo 12

If you want to customize you odoo addon, maybe you can check this link.

Reference

Build up your odoo environment