Closed adsummertech closed 1 year ago
Copying the odoo
folder from the source to my python Libs
directory seemed to help, however Pyright was still struggling to find various definitions.
Switching back to Pylance with the odoo source in the Libs
folder seems to offer the best support.
Hi @adsummertech , the Odoo extension supports resolving imports like from odoo.addons.xxx
where addon xxx
can come from different addons paths attached to your VSCode workspace. Other imports like from odoo import
are resolved in the same way as by the default Python Language Server. Please make sure that you are structuring your Odoo workspace correctly in VSCode. You can use the following sample structure:
We have a multi-root workspace with three folders (three projects):
We also need to setup project dependencies for this workspace by pyrightconfig.json
(same for Pylance) (https://github.com/microsoft/pyright/blob/main/docs/configuration.md).
account-invoicing16
depends on odoo16
, so account-invoicing16/pyrightconfig.json
will be like:
{
"exclude": [
"setup"
],
"extraPaths": [
"../odoo16"
]
}
stock-logistics-warehouse16
depends on odoo16
, so stock-logistics-warehouse16/pyrightconfig.json
will be like:
{
"exclude": [
"setup"
],
"extraPaths": [
"../odoo16"
]
}
I'm not running odoo locally, just working on modules and deploying elsewhere, so that set up doesn't really work for me. I found that copying odoo to the python Libs dir worked best, but will look at a global extraPaths value.
However I'm still getting completion and reference errors when using Pyright. Can't find model.Model
and fields.Many2many
etc etc etc
This doesn't happen if I use Pylance as the language server
As I know, there is no difference in import resolution mechanism between Pylance and Pyright. I see there is duplicated tooltip information in your screenshots. Did you also install the Pyright extension (https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright) beside Pylance?
I had Pylance disabled and Pyright enabled. Language server was set to none.
Can you provide details on how you are structuring your project so I can reproduce the problem on my machine?
It's just a directory of modules, each with a__init__.py
and __manifest__.py
- not an entire project.
I really just wanted code completion and to be able to jump to the source, not sure I need the features of this extension so I think I will stick to pylance with odoo in my lib dir.
Hello.
I've installed the extension and disabled the Python Language Server as per the readme, however the editor is still not resolving any of the modules.