Closed AaronBeaudoin closed 1 year ago
Hi @AaronBeaudoin . Unfortunately, creating namespace packages (odoo/addons) for your custom addons is the only way for odoo.addons.* imports to be understood by pyright/pylance. If you use the Odoo extension, you can make it work by configuring something like this:
"python.analysis.extraPaths": [
"_odoo/community",
"_odoo/enterprise",
"addons/company",
"addons/partner",
"addons/vendor"
]
So when you say in the README:
Both the Odoo source code and your custom addons must be added to your VSCode workspace for the Odoo extension to work as expected. You can use the multi-root workspaces feature to structure your Odoo workspace.
I can do what you suggested above to avoid having to structure my project using multi-root workspaces?
So when you say in the README:
Both the Odoo source code and your custom addons must be added to your VSCode workspace for the Odoo extension to work as expected. You can use the multi-root workspaces feature to structure your Odoo workspace.
I can do what you suggested above to avoid having to structure my project using multi-root workspaces?
Yes. I prefer the multi-root workspace method but your method works fine too.
Hello, I've been using VS Code for Odoo development for some time without your plugin. To get addon imports mostly working I've had my project structured like this:
Then in my
.vscode/settings.json
I have this:As a result, any
from odoo.addons.<whatever> import something
works perfectly as long as<whatever>
is a one of the built-in Odoo modules or an enterprise module. However, this only works because the paths I added toextraPaths
are structured to containodoo/addons
. I don't want to structure my custom addons directory like that, and even if I did it wouldn't work because inside of it I organize my modules into subdirectories something like this because I a have a lot of them:I also don't want to turn my project into a multi-root workspace—I prefer the simplicity of opening a single root directory in VS Code. Is there any way for me to add all of my custom subdirectories to import resolution manually?