Closed ymolinar closed 1 year ago
Hi @ymolinar. Your Odoo workspace needs to be configured a bit for it to work. Because the odoo source code folder is not the root folder of your workspace (it is currently a sub-folder of the root folder, besides other folders such as addons, bin, build,...), the Python language server cannot resolve imports from odoo without additional configuration. To make it work, you can create a pyrightconfig.json
in the root folder of your workspace with something like the following sample:
{
"extraPaths": ["odoo"]
}
Note: odoo
is the relative path to the odoo source code in your workspace.
Also, you should not put the odoo-stubs
folder inside the odoo source code folder. You can put odoo-stubs
outside your workspace and set the relative path to it in pyrightconfig.json
like:
{
"extraPaths": ["odoo"],
"stubPath": "../relative/path/to/odoo-stubs"
}
I simulated your workspace structure and here are my results:
You can learn more about import resolution here: https://microsoft.github.io/pyright/#/import-resolution
Work's like a charm.
I have installed the module following the steps in the documentation and I can't get it to detect the Odoo libraries. The odoo.addons... if they work correctly, the problem is only with the Odoo base libraries This is my project folder organization:
This are the issues
But if i use odoo.odoo works great.