Structure Odoo Projects in PyCharm

Hello world!

How do you structure your Odoo projects in PyCharm? After years of programming Odoo using PyCharm, I want to share with you how I do it. I find it working great so far, not only for me but also for my colleagues.

For example, I have the following Odoo related folders:

Basically, there are two ways to structure these folders in PyCharm: (1) using content roots or (2) using project dependencies. Both need to meet the following requirements:

  • Works with multiple Odoo versions and multiple custom addons repositories at the same time without switching between projects and windows.
  • Works well with the Odoo plugin.


Use content roots

This is my preferred structure. The above folders are grouped by Odoo version. One project per Odoo version. In one project, I will add all related folders as the content roots of the project. Here is the step by step:

  • Open the odoo15 folder as the main project. 
  • In the same PyCharm window, open the odoo16 folder and choose Attach.
  • Open Settings > Project > Python Interpreter to setup Python interpreters for odoo15 and odoo16 projects.
  • Open Settings > Project > Project Structure. Select the odoo15 project, click Add Content Root to add the following folders: odoo-stubs15, account-invoicing15stock-logistics-warehouse15. Do the same for the odoo16 project.

The result will look like the following screenshot:

Use content roots


Use Project Dependencies

This structure is flatter. Each custom addons branch is a separate project. It all depends on another project - the odoo source code. Here is the step by step:

  • Open the odoo15 folder as the main project.
  • In the same PyCharm window, open the account-invoicing15 folder and choose Attach. Do the same for other folders except odoo-stubs*. Once done, we will have the following projects: odoo15account-invoicing15stock-logistics-warehouse15, odoo16account-invoicing16stock-logistics-warehouse16.
  • Open Settings > Project > Python Interpreter to setup Python interpreters for these projects.
  • Open Settings > Project > Project Dependencies. Select the account-invoicing15 project and set the dependency is the odoo15 project. Do the same for other custom addons projects.
  • Open Settings > Project > Project Structure. Select the odoo15 project, click Add Content Root to add the odoo-stubs15 folder. Do the same for the odoo16 project.

The result will look like the following screenshot:

Use project dependencies


Custom scopes

To navigate code more efficiently in a multiple Odoo versions workspace like above, you can create custom scopes. I always have several custom scopes, one for each Odoo version. This way I can use these scopes to search for files, symbols,... more efficiently. For example:

Setup scopes

Searching without scope will yield confusing results:

Search without scope

Searching with a specific scope will yield only relevant results:

Search with scope

After this article, I hope you can use PyCharm and the Odoo plugin more efficiently.