Configure PyCharm to develop with Odoo

Gioacchino Lonardo
Level Up Coding
Published in
3 min readJun 6, 2020

--

Let’s start with a situation where we have a repository on Github where we want to develop our custom Odoo modules.

In the VCS menu, there is the item “Get from version control”

Enter in a URL of the address to clone your repository. For example for GitHub is this:

Installing Odoo

Now we need Odoo’s code! Let’s create a new project in PyCharm with name Odoo for example, and select the attach button. Now we clone Odoo’s repository. You can choose between the various branches where each one represents a version of Odoo. For this example I choose version 12.

Open terminal in ~/PycharmProjects/ and clone the project Odoo on the selected branch:

git clone --single-branch --branch 12.0 https://github.com/odoo/odoo.git

With Pycharm open a folder ~/PycharmProjects/odoo and select Attach so that this situation occurs:

xxx

Python

Odoo requires Python version ≥ 3.5, check with:

 python3 --version

Verify also that pip is installed for this version:

pip3 --version

if you haven’t python3 and/or pip3, to setup python3, pip3 and virtual environment follow this medium story. For example for virtual env. one has:

Deploing Odoo

Add odoo12.conf file in the ~/PycharmProjects/odoo folder:

  • connection parameter for a PostgreSQL server on localhost (db_host) on port 5432 (db_port);
  • using user_test as a user for DB (db_user) and pass_test for DB password ( db_password);
  • addons_path where the folders containing custom modules are inserted separated by a comma;

For more information see Deploying Odoo.

PyCharm Configuration

Go to the drop-down menu and then to edit configurations…, this will open a new window.

In the Script path you have to insert the path in which odoo-bin is contained. As a Parameter we will give him -c and the configuration file. As Project we choose the one in which we will insert the custom modules, in this case learn odoo. The Python interpreter must be the one you previously created in the odoo folder. Working directory in general is where there is odoo configuration file.

Python Interpreter

If you can’t find the python interpreter in the previous window then you have to create or add it. Just go to File →Settings →Project →Python interpreter →Add.

Conclusion

With this approach we use a repository for custom modules and another one to clone the branch, then the version, of Odoo we want to use. If you start from scratch without Odoo and PostgreSQL a very interesting link is recommended and examples are shown. It shows how to configure the IDE. Now all you have to do is play or activate the debug mode!

--

--