DevelopmentTutorials

How to Configure Odoo 16 in Visual Studio Code on Unbuntu 20.04

Odoo 16 is a powerful open-source business management software suite, and Visual Studio Code (VS Code) is a popular code editor among developers. Setting up an Odoo 16 development environment in VS Code on Ubuntu 20.04 can streamline your development process. To get started, ensure that you meet the following prerequisites:

Step 1: Install Python 3.8 and Required Packages

Begin by updating your package list and installing essential dependencies:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8

Next, install important Python packages and libraries:

sudo apt-get install python-dev python3-dev build-essential libjpeg-dev libpq-dev libjpeg8-dev libxml2-dev libssl-dev libffi-dev libmysqlclient-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev liblcms2-dev

Install web dependencies:

sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less

To create Odoo reports, install wkhtmltopdf:

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

Step 2: Install PostgreSQL

Install PostgreSQL and create a Database User Role for handling Odoo databases:

sudo apt-get install postgresql
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo16
# Set a password when prompted
psql
ALTER USER odoo16 WITH SUPERUSER;
\q
exit

Step 3: Install Visual Studio Code

Install VS Code using Snap or follow alternative download options:

sudo snap install --classic code

Step 4: Download Odoo 16 Source Code

Download the Odoo 16 Community Source Code directly from the Odoo Github repository or clone it with Git:

git clone https://github.com/odoo/odoo.git --depth 1 --branch 16.0 --single-branch odoo16
cd odoo16

Install Python packages listed in the requirements.txt file:

sudo pip3 install -r requirements.txt

Step 5: Configure Odoo in Visual Studio Code

Install necessary VS Code extensions like Python and PyLance to enhance your coding experience.

Step 6: Open Odoo16 Project Folder in VS Code

Step 7: Create odoo.conf File

Create an odoo.conf file inside the Odoo16 directory. Modify the following configuration, replacing <db_password> with the password you set for the odoo16 database user, and adjust the addons_path:

[options]
admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = odoo16
db_password = <db_password>
addons_path = /home/user/odoo/addons
xmlrpc_port = 8016

Step 8: Configure launch.json

In VS Code, go to Run > Add Configuration > Node.js to open launch.json. Replace its content with the following configuration, specifying the paths to odoo-bin and odoo.conf:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Run Odoo",
      "type": "python",
      "request": "launch",
      "stopOnEntry": false,
      "console": "integratedTerminal",
      "program": "/home/cybrosys/odoo16/odoo-bin",
      "args": [
        "--config=/home/cybrosys/odoo16/odoo.conf"
        // "--database=db_1_name,db_2_name",
        // "--update=module1_name,module2_name"
      ]
    }
  ]
}

You can now run Odoo using VS Code after saving the file.

This guide should help you set up a robust Odoo 16 development environment with Visual Studio Code on Ubuntu 20.04, making your Odoo development tasks more efficient. For more details, you can explore the Odoo 16 Installation blog.

Related Articles

Leave a Reply

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

Back to top button