如何在 Ubuntu 中的 Visual Studio Code 上开发(运行和调试)Odoo v11 模块?

2023-11-25

是否可以在 Visual Studio Code 上运行和调试 Odoo?如果是,请分享我的配置。

视觉工作室代码是 Microsoft 为 Windows、Linux 和 macOS 开发的源代码编辑器。它包括对调试、嵌入式 Git 控制、语法突出显示、智能代码完成、代码片段和代码重构的支持。它是免费且开源的,但官方下载需要专有许可证。


我知道我有点晚了,但我已经成功地使用 Odoo 11。

我的安装路径是“C:\Program Files (x86)\Odoo 11.0\server”

现在打开 VS Code 并转到工作区设置并粘贴以下内容:

{
"python.pythonPath": "C:\\Program Files (x86)\\Odoo 11.0\\python\\python.exe",
"python.linting.pylintEnabled": false,
// use this so the autocompleate/goto definition will work with python extension
"python.autoComplete.extraPaths": [
    "${workspaceRoot}/odoo/addons",
    "${workspaceRoot}/odoo",
    "${workspaceRoot}/odoo/openerp/addons"
],
//"python.linting.pylintPath": "optional: path to python use if you have environment path",
"python.linting.enabled": false,
//load the pylint_odoo
"python.linting.pylintArgs": [
    "--load-plugins",
    "pylint_odoo"
],
"python.formatting.provider": "yapf",
//"python.formatting.yapfPath": "optional: path to python use if you have environment path",
// "python.linting.pep8Path": "optional: path to python use if you have environment path",
"python.linting.pep8Enabled": true,
// add this auto-save option so the pylint will sow errors while editing otherwise
//it will only show the errors on file save
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 500,
// The following will hide the compiled file in the editor/ add other file to hide them from editor
"files.exclude": {
    "**/*.pyc": true
}

}

保存并打开 vs "C:\Program Files (x86)\Odoo 11.0\server\odoo" 中的代码文件夹

然后转到调试设置和新的配置文件并粘贴以下代码:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "Python: Odoo",
        "type": "python",
        "request": "launch",
        "stopOnEntry": false,
        "pythonPath": "${config:python.pythonPath}",
        "console": "externalTerminal",
        "program": "${workspaceRoot}\\..\\odoo-bin",
        "args": [
            "--config=${workspaceRoot}\\..\\odoo.conf",
        ],
        "cwd": "${workspaceRoot}",
        "env": {},
        "envFile": "${workspaceRoot}/.env",
        "debugOptions": [
            "RedirectOutput"
        ]
    }
]

}

然后点击运行按钮。请记住 vs code 可能会给您一些警告,请按忽略按钮并等待控制台打开,然后您就完成了。享受调试和编码。

不要忘记停止奥多服务从窗口服务。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 Ubuntu 中的 Visual Studio Code 上开发(运行和调试)Odoo v11 模块? 的相关文章

随机推荐