vscode-odoo
vscode-odoo copied to clipboard
cannot resolve from odoo.addons.* when the module is in oca folder or enterprise
Hi, on my local i'm developing on visual code and I'm using some modules from oca and enterprise. it cannot resolve the imports from there. "Import "odoo.addons.fastapi.tests.common" could not be resolved"
the addon path is correctly configured, in fact all modules work perfectly.
instead native odoo addons and my homemade modules that are in the addons folder are correctly displayed in the autocomplete for that reason i believe is a misconfiguration but i cannot figurate out how to fix it.
i'm developing on mac, my folder structure is
. ├── addons ├── build ├── config ├── enterprise ├── k3s ├── oca ├── odoo ├── scripts ├── snippets ├── template ├── themes ├── thirdparty ├── tmp └── venv16.0
my addon path shows
INFO ? odoo: addons paths: ['/Volumes/DEV/odoo-myproject/odoo/odoo/addons', '/Volumes/DEV/odoo-myproject/venv16.0/lib/python3.11/site-packages/odoo/addons', '/Users/dd/Library/Application Support/Odoo/addons/16.0', '/Volumes/DEV/odoo-myproject/themes', '/Volumes/DEV/odoo-myproject/odoo/addons', '/Volumes/DEV/odoo-myproject/oca/partner-contact', '/Volumes/DEV/odoo-myproject/addons/server_tools', '/Volumes/DEV/odoo-myproject/oca/web', '/Volumes/DEV/odoo-myproject/oca/server-tools', '/Volumes/DEV/odoo-myproject/oca/sale-workflow', '/Volumes/DEV/odoo-myproject/oca/purchase-workflow', '/Volumes/DEV/odoo-myproject/oca/server-env', '/Volumes/DEV/odoo-myproject/addons/sale_workflow', '/Volumes/DEV/odoo-myproject/addons/hr', '/Volumes/DEV/odoo-myproject/addons/purchase_workflow', '/Volumes/DEV/odoo-myproject/enterprise', '/Volumes/DEV/odoo-myproject/oca/bank-payment', '/Volumes/DEV/odoo-myproject/oca/server-backend', '/Volumes/DEV/odoo-myproject/oca/account-invoicing', '/Volumes/DEV/odoo-myproject/addons/partner_contact', '/Volumes/DEV/odoo-myproject/addons/account_invoicing', '/Volumes/DEV/odoo-myproject/addons/mymodules', '/Volumes/DEV/odoo-myproject/oca/web-api', '/Volumes/DEV/odoo-myproject/oca/rest-framework', '/Volumes/DEV/odoo-myproject/oca/server-auth']
in the oca folder there are the modules i'm using, and as said are perfectly working in my odoo instance
oca ├── account-invoicing ├── bank-payment ├── partner-contact ├── purchase-workflow ├── rest-framework ├── sale-workflow ├── server-auth ├── server-backend ├── server-env ├── server-tools ├── web └── web-api
Hello @davdenic ,
If the extension cannot detect addons paths automatically, you can manually add addons paths to the python.analysis.extraPaths setting.
i've already tried but it doesn't work
"python.analysis.extraPaths": [ "./odoo", "./oca", "./oca/rest-framework", "./oca/rest-framework/fastapi", "/Volumes/DEV/odoo-myproject/oca", "/Volumes/DEV/odoo-myproject/oca/rest-framework", "./enterprise", "....", "...", "..", ],
@davdenic ,
Can you provide screenshots of the import errors, your VSCode workspace structure and the extraPaths setting?
this is the screenshot of the error, the workspace structure reflect what i've already submitted in the first message, the extraPaths is written just 2 posts above
@davdenic ,
I just tested, everything is still working fine.
@davdenic I had the same problem, and I fixed it by running 'Python: Clear Cache and Reload Window' from the command palette in VSCode after updating the extraPaths
I have the same issue. Still trying to solve it.
@davdenic I just solved the issue by configuring the python.analysis.extraPaths. I am pretty sure your issue is also related to that.
Please try to define the extra paths in the following way:
"python.analysis.extraPaths": [ "/absolute_path_to_folder/odoo", "/absolute_path_to_folder/oca", "/absolute_path_to_folder/enterprise", "/absolute_path_to_folder/addons", ],
Also, please be sure that all the paths are really loaded by VS code. How did you define the paths? Can you show me your settings.json file?
I have same problems in my dev container:
@leimantas ,
Beside the extraPaths setting, you also need to open the Odoo source code (/usr/lib/python3/dist-packages/odoo) in VSCode for indexing. This limitation will be addressed in the future versions.
i have symbolic link to odoo source
@leimantas ,
The extension excludes hidden files (.odoo) from indexing.
Thanks :) It works now!
What about Magic Fields validation?
I have this small demo with Odoo Dev Container. https://github.com/leimantas/odoo-dev
@leimantas ,
The magic fields are declared in odoo-stubs. The extension needs to detect your odoo version to set the corresponding odoo-stubs. There may a problem with your project structure so the extension failed to detect your odoo version. Please make sure the symbolic link to the odoo source code is also named odoo. A working project structure looks like:
-- root project (open in VSCode)
|-- odoo source code
|-- custom addons path 1
|-- custom addons path 2
I have a problem that seems to be related. I use vscode on macOS with apple silicon with a devcontainer.
It seems like the imports can be resolved. it does the indexing on the correct paths and there are no error in the imports. but when that is done I get no suggestions at all. When hitting the suggestions shortcut it says "No suggestions."
my directory structure:
Odoo-Dev ├── .devcontainer │ ├── Dockerfile │ ├── devcontainer.json │ └── docker-compose.yml ├── .vscode │ ├── launch.json │ └── settings.json ├── odoo │ ├── CONTRIBUTING.md │ ├── ... │ └── setup.py ├── odoo_enterprise ├── LICENSE ├── ... └── setup.py ├── odoo_addons_dev │ └── my_addon_proj └── odoo.conf
Can anyone help?
@jankkm ,
Can you take some screenshots of your problem?
you can see here that the imports are resolved but I do not get suggestions for fields.
Is there something in particular that you need to see?
@jankkm ,
Can you take a screenshot when hovering fields?
@jankkm ,
Your problem is strange. Can you take a screeshot of your project structure in VSCode?
my odoo.conf:
[options]
db_host = odoo-dev_devcontainer-db-1
db_port = 5432
db_user = odoo
db_password = odoo
addons_path = /workspaces/Odoo-Dev/odoo_enterprise/odoo/addons,/workspaces/Odoo-Dev/odoo_addons_dev
default_productivity_apps = True
devcontainer.json
{
"name": "Odoo using Python 3 & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"forwardPorts": [
5432,
8069
],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {},
"extensions": [
"ms-python.autopep8",
"ms-python.debugpy",
"ckolkman.vscode-postgres",
"mechatroner.rainbow-csv",
"ms-azuretools.vscode-docker",
"redhat.vscode-xml",
"formulahendry.auto-rename-tag",
"formulahendry.auto-close-tag",
"trinhanhngoc.vscode-odoo"
]
}
}
}
I think with that you can get an idea how I set this thing up.
@jankkm ,
I could not reproduce the problem. You can try testing if a simpler project structure with just the odoo source code (without odoo_addons_dev, odoo_enterprise) has the same problem.
Now we're getting closer. The most basic setup you showed does work!
Also in my initial setup, if I remove the odoo_enterprise directory, it works fine.
I noticed that with the enterprise code included the indexing process takes quite a long time (1-2 minutes maybe) and it seems to have finished a couple times but then starts again.
@jankkm ,
So the problem is caused by your enterprise folder. Can you take a screenshot of the structure of your enterprise folder?
thanks for being so helpful!!
@jankkm ,
Your enterprise folder is a full version of odoo, not just the enterprise addons. I think it's the problem. Try to use the community version OR the enterprise version, not both.
- odoo community
- enterprise addons
- custom addons 1
- custom addons 2
- odoo enterprise
- custom addons 1
- custom addons 2
@jankkm ,
Your enterprise folder is a full version of odoo, not just the enterprise addons. I think it's the problem. Try to use the community version OR the enterprise version, not both.
- odoo community - enterprise addons - custom addons 1 - custom addons 2- odoo enterprise - custom addons 1 - custom addons 2
that indeed was the issue. running just the enterprise works fine. thank you so much for helping me out!