Open michaelkarrer81 opened 3 years ago
IMHO changing the way we clone repos isn't a very good option because we might be introducing some conflicts with the way we handle repos, addons, and the integration with git-aggregator
. It could become a very complex change.
Another solution, however, could be adding those paths dynamically to the settings with the invoke
task as we do with the debugger path mappings.
WDYT @Yajo?
Another solution, however, could be adding those paths dynamically to the settings with the invoke task as we do with the debugger path mappings.
Could you give an example?
The only settings i found that would influence code completion was in tasks.py > write_code_workspace_file()
cw_config["settings"].update(
{
"python.autoComplete.extraPaths": [f"{str(SRC_PATH)}/odoo"],
"python.languageServer": "Jedi",
I guess adding e.g. odoo/custom/src/web
to extraPaths would not help because still the structure is not odoo/addons/[addon]
but web/[addon]
.
But i may just don't know the vs-code python settings well enough to get your point?
I agree with you @joao-p-marques.
I guess adding e.g.
odoo/custom/src/web
to extraPaths would not help because still the structure is notodoo/addons/[addon]
butweb/[addon]
.
I don't think that's enough.
For python (and I guess vscode) to interpret a folder as a module, usually the folder needs to have a __init__.py
file inside (even if empty).
If it were so simple, one solution (at least for OCA addons) would be to include the setup
folder inside OCA repos. This random example shows it has the same structure you're asking for, @michaelkarrer81.
If this worked, that'd mean the only ones left out of luck would be private
and non-OCA repos. But both cases would probably be easy to fix by leveraging the toolset OCA uses for generating those setup
folders.
For me this auto-completion doesn't bring too much value compared with the setup process, as the real killer feature will be to interpret the ORM essence (type env["res.partner"].
and bring you the list of fields for example). Odoo mentioned in last OXP AMA that they want to put a VSCode plugin for getting this.
this auto-completion doesn't bring too much value [...] the real killer feature will be to interpret the ORM essence (type env["res.partner"]. and bring you the list of fields for example).
Yes, it'd help mostly when doing controllers, but models would remain mostly the same.
compared with the setup process
We don't really need to add the setup folder, but for cases when it already exists, we can benefit from it.
Odoo mentioned in last OXP AMA that they want to put a VSCode plugin for getting this.
I don't trust Odoo's promises anymore. Anyways, let's leave this issue open in case somebody from the community wants to add support. It wouldn't be so hard nor harm anybody.
Lately autocompletion was added for visual studio code by switching the language server to
jedi
and addingpython.autoComplete.extraPaths
.This will enable autocompletion for all addons in the odoo source because they are under
odoo/addons
andodoo/odoo/addons
. Soimport from odoo.addons.website_sale ...
will work because the path matches.../odoo/addons
.But this will not work for addons of other e.g. OCA addon repositories because the addons will be e.g. in
odoo/custom/src/web/[addon_name]
so the import path no longer matchesodoo/addons
.Solutions:
One easy solution might be to clone all the external addon repos like this:
odoo/custom/src/web/odoo
addons
inside this new folderstructure:odoo/custom/src/web/odoo/addons
...custom/src/private/odoo/addons/[private addons here]
Another solution would be to create the final odoo structure by symlinking like in the auto folder. But i am not sure how well vs-code works with symlinks - pycharm has it's problems with it... Therefore i would prefer the first solution.