This blog will help you to configure Odoo 14 development environment using Pycharm IDE. Here you will learn step by step procedures to set up the odoo development environment.
Step-1: Install Pycharm IDE on your PC
The required configuration to install Pycharm in your PC:
||64-bit of Linux distribution that supports Gnome,
KDE, or Unity DE,
Microsoft Windows 8 or later and macOS 10.13 or later
|A latest 64-bit version of Windows, macOS, or Linux
||4 GB of free RAM
||8 GB of total system RAM
||2.5 GB and another 1 GB for caches
||SSD drive with at least 5 GB of free space
To install Pycharm, first, update your system. Open terminal with Ctrl + Alt + T and run the following command.
sudo apt-get update
sudo apt-get upgrade
Then install pycharm IDE. We can install Pycharm using several methods and available in 3 different editions: Professional, Community, and Edu. Here we are using snap packages for the installing community edition.
sudo snap install pycharm-community --classic
Step 2: Installing Python Packages
Next install some python packages and libraries.
sudo apt-get install -y python3-pip
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
Then 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
Install wkhtmltopdf which is required for Odoo reports
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: 3: Installation and Configuration of PostgreSQL
sudo apt-get install postgresql
After the installation create a new PostgreSQL user for handling Odoo databases
Change user to postgres
sudo su - postgres
Create user odoo14 with the following command
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo14
Provide password for the user and remember the user's name and password. We need those in later steps.
Then make the user as a superuser:
ALTER USER odoo14 WITH SUPERUSER;
Now exit from the psql and postgres user using the commands.
Step 4: Get Odoo 14 Source Code
Download source files of Odoo 14. You can clone it or download it manually from Odoo's GitHub repository. Here we clone it from the Odoo Repository. For that, make sure git is installed in your system.
sudo apt-get install git
Let's clone Odoo 14 using the following command. It will clone to a new directory 'odoo' (specified in the command after - single-branch ) in your home directory.
git clone https://www.github.com/odoo/odoo --depth 1 --branch 14.0 --single-branch odoo
Step 5: Install Required Python Dependencies
After the clone, we need to install the required python dependencies which are listed in file requirement.txt within the Odoo directory.
sudo pip3 install -r requirements.txt
sudo pip3 install -r <path> /requirements.txt
Replace <path> with the location of the required file.
Must ensure that all dependencies are installed successfully. Otherwise, it may cause problems to run odoo
Step 6: Setup Odoo Configuration
Now Open Pycharm -> Open Project -> Select Odoo directory .
Then create a new configuration file 'odoo.conf' inside the odoo directory.
You can paste this following configuration to the conf file
; Is This The Password That Allows Database Operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = odoo14
db_password = False
addons_path = /home/user/odoo/addons
xmlrpc_port = 8014
Change db_password with the password of the database user odoo 14. Also, change the addons_path with the path of the addons directory.
To get the proper path click on the addons directory and press Ctrl + Shift + C to copy the path and paste it on the addons_path. To add your custom modules you can create another directory and paste the path into the addons path separated by a comma. for example,
addons_path = /home/user/odoo/addons, /home/user/odoo/custom_addons
Odoo using 8069 as default port number. You can change this using xmlrpc_port if you want.
Step 7: Add Configuration to pycharm
Next we need to set configuration in Pycharm. Click the Add Configuration button in the below screenshot
It will open another dialog box. Click the + button and select Python. Configure with the following settings
Name: You can give name for the Configuration
Script Path : Here you have to select the 'odoo-bin' file from odoo directory by clicking the marked icon.
Parameters : Here we provide the parameters for running odoo service. at least provide the conf file using -c parameter as shown in the above picture.
Python Interpreter : Select Python Interpreter here.
Step 8: Run odoo with pycharm
Your development environment now ready for running. You can test the configuration by the run button.
If Odoo run without any error or issue the log should be like this
Here 'cybrosys' is the username of the system. Now you can access Odoo in a web browser by localhost: 8014. It will redirect to the database manager.
Maybe you will get an 504 error. There are several possibilities to get this error.
Check the log in Pycharm. Ensure that all the dependencies from requirement.txt are successfully installed or if it is "Peer Authentication Error", then you can solve it by the following steps.
sudo nano /etc/postgresql/12/main/pg_hba.conf
Check your postgres version and replace it with '12' in the command. This will open the conf file in the terminal. Add a line in the file as shown below
local all odoo14 trust
Then Ctrl + X -> Press Y -> Press Enter
Restart PostgreSQL service
sudo service postgresql restart
Now again Run Odoo 14 in Pycharm. And try it in a web browser.