vscode-odoo icon indicating copy to clipboard operation
vscode-odoo copied to clipboard

Python refactoring options deactivated when extension is activated

Open mathisgauthey opened this issue 1 year ago • 3 comments

Hi there.

Just found out that when using your extension, the python extract refactoring stops working. I don't know why, but this is really important in my workflow, and I don't think this is happening on the PyCharm extension.

Thanks in advance !

mathisgauthey avatar May 24 '24 08:05 mathisgauthey

Hello @mathisgauthey ,

This is a known limitation. Some refactoring features are only available when using the default Python language server (Pylance). Because the Pylance language server is not extensible, I must build a new language server for Odoo, which is currently missing some features from Pylance.

trinhanhngoc avatar May 24 '24 08:05 trinhanhngoc

Hello @mathisgauthey ,

This is a known limitation. Some refactoring features are only available when using the default Python language server (Pylance). Because the Pylance language server is not extensible, I must build a new language server for Odoo, which is currently missing some features from Pylance.

Thanks for the answer. I noticed that removing the "python.languageServer": "None", allows to get the Pylance refactor options while preserving the vscode-odoo auto completion and features. I just get a few unresolved imports from pylance, which is normal, but it allows to benefir from such a feature.

Would it be possible to allow for an option to prevent vscode-odoo from adding this line to settings.json ?

mathisgauthey avatar May 24 '24 10:05 mathisgauthey

@mathisgauthey ,

OK. I will consider adding that option to the next version.

trinhanhngoc avatar May 24 '24 13:05 trinhanhngoc

Hello, just had a chat with some colleagues about this amazing extension. I got used to never have suggestion like in the following image. This is fixed if I removed the "python.languageServer": "None" as suggested by @mathisgauthey . The thing is that it's added back if I restart the IDE. If I understood correctly, this is meant to be by the extension so I'm fine with it.

Still, can you tell for what this is needed ? I mean, if I comment this setting out, which features are going to be impacted ?

Thank you !

Image

xavierdubuc avatar Jun 05 '25 08:06 xavierdubuc

Hello @xavierdubuc ,

If you disable that setting ("python.languageServer": "None"), the default Python language server (Pylance) will be activated, and you will have two activated language servers (Odoo IDE and Pylance). You will see duplicated code completion items, false diagnostics from Pylance (because Pylance does not understand Odoo ORM),... My plan is to add some important Pylance features (quick fix for imports,...) to the Odoo IDE language server.

trinhanhngoc avatar Jun 06 '25 07:06 trinhanhngoc

Hi @trinhanhngoc , first, thank you for this amazing plugin which is so handy ! Also, thank you for the quick & clear answer. I'll just wait patiently then :) !

Have a nice day !

xavierdubuc avatar Jun 06 '25 13:06 xavierdubuc