How to allow linter to resolve imports through Odoo's `odoo.addons`?

Viewed 86

How do I set up my development environment so my IDE is able to properly resolve imports through odoo.addons?

In some cases in Odoo one may need to import Python objects directly from a file in another custom module. Take a module some_module as an example. In some_module/models/some_model.py there might be an import like so:

from odoo.addons.other_module import some_class

This type of import is done throughout the Odoo source code, and everything is resolved without issues because the built-in Odoo modules are located directly under the odoo/addons directory which has an __init__.py file. However, since my custom modules are in a separate directory, the linter is obviously not able to resolve the imports.

What's the recommended way to deal with this?

1 Answers
Related