How to setup Odoo 15 on Ubuntu 20.04 using VSCode?

HARSHAD
November 27, 2021

Odoo has been stealing the limelight in the ERP Industry. Lots of new developers are choosing to jump into Odoo development. This blog post is a guide to these new developers and existing Odoo developers. It is recommended to use a Linux environment preferably a distro based on Debian, like Ubuntu, for development purposes and this guide assumes that you are on Ubuntu 20.04.

You can find the commands and steps, with a brief explanation, to be taken to set up the development environment below.

First, we need to add some extra sources to download a few packages:

 sudo apt-get install software-properties-common -y sudo add-apt-repository universe sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu/ xenial main" 

The below source is used to install `libpng-12` dependency for `wkhtmltopdf`

sudo add-apt-repository ppa:linuxuprising/libpng12

Now let us update the system

sudo apt update
sudo apt upgrade

Install PostgreSQL which is used to store the data from Odoo. We are specifically installing PostgreSQL 12, but you can change the version as you like.

sudo apt install postgresql-12 postgresql-server-dev-all -y

The next thing we need to do is create a user for the same. Since we are doing Odoo 15 development, we are going to create a PostgreSQL user named ‘odoo15’.

sudo -u postgres -i
createuser --createdb --username postgres --no-createrole  --no-superuser --pwprompt odoo15

Python 3.8 comes pre-installed with Ubuntu 20.04 and we are planning to use the same for our purposes. Let us install some packages which we need.

 sudo apt install git python3 python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libjpeg-dev gdebi xfonts-base xfonts-75dpi libpng12-0 -y 

Now we can install NodeJS, NPM, `rtlcss` for RTL support

sudo apt install nodejs npm -y
sudo npm install -g rtlcss
sudo npm install -g less
sudo npm install -g less-plugin-clean-css

The next thing we need to do is to install `wkhtmltopdf` so that PDF can be printed from Odoo.

sudo wget "https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.
focal_amd64.deb"
sudo apt install ./wkhtmltox_0.12.5-1.focal_amd64.deb
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin

Let’s start installing python dependencies

sudo -H python3 -m pip install "https://raw.githubusercontent.com/odoo/odoo/15.0/requirements.txt"
sudo -H python3 -m pip install psycopg2-binary pdfminer.six num2words ofxparse dbfread ebaysdk
firebase_admin pyOpenSSL 

Now we have all the dependencies installed. The next thing we need to do is download the Odoo source code from GitHub. You can either download the source code as a zip file from GitHub or you can clone the same for commit history and easily update the source code with the latest changes. We will be cloning the Odoo source code. Let us create a new folder to hold all our Odoo 15 related files.

How to setup odoo 15 on Ubuntu 20.04 using VSCode?
How to setup odoo 15 on Ubuntu 20.04 using VSCode? Odoo 15 on Ubuntu 20.04
mkdir odoo15
git clone https://github.com/odoo/odoo -b 15.0 server-code

In the above commands, we are creating a directory named odoo15 to hold all our odoo15 related files. Then we are cloning the Odoo 15 source code to a folder named server-code. We are sure that it is code for Odoo 15 since we passed the argument `-b 15.0`. Since we gave a name server-code at the end, it will clone the code to a folder named server-code. If you don’t need the whole commit history, you can use the depth command to fast up the cloning process. In the below command only the last commit will be fetched. You can change the number as per your needs.

git clone https://github.com/odoo/odoo -b 15.0 --depth=1 server-code

Next, we can start configuring VSCode for Odoo development. To install VSCode, the easiest method is using the snap store.

sudo snap install code --classic

This will install VSCode in your system. Either you can open VSCode from your application launcher or you can navigate to the Odoo 15 folder which we created earlier and use the below command to open VSCode with that particular folder opened.

cd odoo15
code .

Additionally, we need to install Python Extension in VSCode. Navigate to extensions in VSCode, search for Python and install the same.

Once you have installed the Python extension, use the shortcut key “Ctrl+Shift+P” and search “Python: Select Interpreter” and select the correct Python version, in our case “Python 3.8 (/usr/bin/python3)”. After you have selected Python as interpreter, navigate to Debug Tab and click on create a launch.json file and select Python from the list and then select current file. Once you do that you can see it creates a “.vscode” folder in the root of your current directory with a file called “launch.json” file. Open the file and replace the content with the one given below.

 {

"configurations": [

{

"name": "Odoo Debug",

"type": "python",

"request": "launch",

"program": "${workspaceFolder}/server-code/odoo-bin",

"args": [

"--config=${workspaceFolder}/odoo15.conf",

],

"cw": "${workspaceRoot}",

"console": "integratedTerminal"

}

]

} 

The {workspaceFolder} refers to your current open directory in VSCode. Also, don’t forget to create your “odoo15.conf” file in the root of your directory just like in the “launch.json” file. Once everything is properly set up, you can use the F5 key to Start Debugging your application.
We are currently in the works to create a script that automatically sets up everything for you. Keep on the lookout for the same. 🙂

DOWNLOAD ODOO 

We’re available by phone or email, with a 24-hour response time in case you need immediate Odoo support. For more details, Call us on +91 88912 49995 or +91 70250 75566 email us at info@bassaminfotech.com

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *