DevelopmentTutorials

How to Configure Odoo 13 in Visual Studio Code on Ubuntu 20.04: A Step by Step Guide

Introduction

Odoo is a powerful open-source business application suite that includes a wide range of business applications, such as CRM, inventory management, e-commerce, and more. If you’re looking to develop and customize Odoo, Visual Studio Code is an excellent choice for your code editor. In this step-by-step guide, we’ll walk you through the process of configuring Odoo 13 in Visual Studio Code on Ubuntu 20.04.

Prerequisites

Before we dive into the installation and configuration process, let’s ensure you have all the prerequisites in place:

1. Ubuntu 20.04 Installed

Make sure you have a clean and updated installation of Ubuntu 20.04 on your system. You can either install it on your machine or use a virtual machine for development.

2. Visual Studio Code Installed

If you don’t have Visual Studio Code installed, you can download and install it from the official website or through the Ubuntu Software Center.

3. Python 3 Installed

Odoo 13 requires Python 3.6 or later. You can check your Python version using the following command:

python3 --version

If Python 3 is not installed, you can install it using:

sudo apt update
sudo apt install python3

4. PostgreSQL Installed

Odoo uses PostgreSQL as its database system. You can install PostgreSQL with the following command:

sudo apt update
sudo apt install postgresql

5. Odoo 13 Installed

You can install Odoo 13 on your Ubuntu system. To install Odoo, open your terminal and run the following commands:

sudo apt update
sudo apt install git python3-pip build-essential wget python-dev python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libopenjp2-7 libtiff5 libjpeg8 zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxslt1-dev libxml2-dev libtiff5 libjpeg8 libjpeg-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libmysqlclient-dev libssl-dev libffi-dev libxslt1-dev libsasl2-dev libldap2-dev libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libopenjp2-7 libtiff5 libjpeg8 zlib1g-dev libfreetype6-dev liblcmlibjpeg8 zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxslt1-dev libxml2-dev libjpeg-dev libmysqlclient-dev libsasl2-dev libldap2-dev libssl-dev libffi-dev libmysqlclient-dev
git clone https://www.github.com/odoo/odoo --depth 1 --branch 13.0 --single-branch .
sudo pip3 install -r requirements.txt

Configuring Odoo in Visual Studio Code

With all the prerequisites in place, let’s move on to configuring Odoo 13 in Visual Studio Code.

1. Open Visual Studio Code

Launch Visual Studio Code from your system. If you haven’t used it before, you’ll find it in your application menu.

2. Install Python Extension

To work with Python in Visual Studio Code, you’ll need the Python extension. You can install it from the Visual Studio Code marketplace. Search for “Python” and click the “Install” button for the one published by Microsoft.

3. Create a New Workspace

In Visual Studio Code, you can create a workspace to organize your project files. Go to “File” > “New Workspace…” and choose a directory where you’d like to create your workspace.

4. Open Odoo Project

With your workspace created, it’s time to open your Odoo project. Click on “File” > “Open Folder…” and navigate to the folder where you installed Odoo.

5. Create a Python Virtual Environment

It’s good practice to work within a Python virtual environment. In your terminal, navigate to your Odoo project folder and create a virtual environment by running the following command:

python3 -m venv venv

Activate the virtual environment:

source venv/bin/activate

6. Install Required Python Packages

While your virtual environment is active, install the necessary Python packages for Odoo. You can do this by running the following command:

pip install -r requirements.txt

7. Configure Odoo Settings

Next, you’ll need to configure Odoo settings. In your Odoo project folder, you can find a configuration file named `odoo.conf`. You can create a copy of it and edit the settings accordingly. For example:

[options]
; This is the password that allows database operations:
admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /path/to/your/addons
logfile = /path/to/your/logfile

Make sure to replace `/path/to/your/addons` and `/path/to/your/logfile` with the actual paths to your Odoo addons and log file.

8. Set Up PostgreSQL Database

Odoo uses PostgreSQL as its database system. Create a PostgreSQL user and database for your Odoo instance. You can do this by running the following commands:

sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
createdb --username odoo --owner odoo mydb
exit

Replace `mydb` with the name you want to use for your database.

9. Start Odoo Server

With everything set up, you can start the Odoo server. In your terminal, navigate to your Odoo project folder and run:

./odoo-bin -c odoo.conf

This will start the Odoo server, and you can access it through your web browser by going to `http://localhost:8069`.

10. Developing with Visual Studio Code

You’re now ready to start developing with Odoo in Visual Studio Code. You can create new Odoo modules, customize existing ones, and work on your business applications right within the editor.

Remember to activate your virtual environment every time you work on your Odoo project:

source venv/bin/activate

Conclusion

Configuring Odoo 13 in Visual Studio Code on Ubuntu 20.04 is a straightforward process when you follow these step-by-step instructions. With this setup, you can efficiently develop and customize your Odoo business applications, making it easier to manage your business operations. Happy coding!

Related Articles

Leave a Reply

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

Back to top button