-
Notifications
You must be signed in to change notification settings - Fork 5
Structure Odoo Projects
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:
-
odoo15,odoo16: corresponding to the 15.0, 16.0 branches of the Odoo community repository (https://github.com/odoo/odoo). -
account-invoicing15,account-invoicing16: corresponding to the 15.0, 16.0 branches of the OCA invoicing addons repository (https://github.com/OCA/account-invoicing). -
stock-logistics-warehouse15,stock-logistics-warehouse16: corresponding to the 15.0, 16.0 branches of the OCA warehouse addons repository (https://github.com/OCA/stock-logistics-warehouse).
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.
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
odoo15folder as the main project. - In the same PyCharm window, open the
odoo16folder and choose Attach. - Open
Settings > Project > Python Interpreterto setup Python interpreters forodoo15andodoo16projects. - Open
Settings > Project > Project Structure. Select theodoo15project, click Add Content Root to add the following folders:account-invoicing15,stock-logistics-warehouse15. Do the same for theodoo16project. The result will look like the following screenshot:
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
odoo15folder as the main project. - In the same PyCharm window, open the
account-invoicing15folder and choose Attach. Do the same for other folders. Once done, we will have the following projects:odoo15,account-invoicing15,stock-logistics-warehouse15,odoo16,account-invoicing16,stock-logistics-warehouse16. - Open
Settings > Project > Python Interpreterto setup Python interpreters for these projects. - Open
Settings > Project > Project Dependencies. Select theaccount-invoicing15project and set the dependency is theodoo15project. Do the same for other custom addons projects. The result will look like the following screenshot:
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:

Searching without scope will yield confusing results:

Searching with a specific scope will yield only relevant results:
