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

标签 python debugging visual-studio-code odoo odoo-11

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

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is free and open-source, although the official download is under a proprietary license.

最佳答案

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

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

现在打开 vs 代码并转到工作区设置并粘贴:

{
"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 可能会给你一些警告按下忽略按钮并等待控制台打开你就完成了。享受调试和编码的乐趣。

不要忘记从窗口服务中停止 Odoo 服务

关于python - 如何在 Ubuntu 的 Visual Studio Code 上开发(运行和调试)Odoo v11 模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48033323/

相关文章:

python - 使用 BeautifulSoup 提取值列表

python - 通过 PyFacebook 访问 Facebook Connect FBML cookie?

c - 如果该数据仅在 C 函数返回时可用,如何使用 LLDB 自动捕获输出数据?

visual-studio-code - VS Code 中的可点击链接 API

visual-studio-code - 配置 V.S. 的可见性代码滚动条

javascript - VS 代码片段到当前行下方的 console.log 选择

java - 从大小 > 10GB 的大文件中读取行范围的快速方法

python - 在 python 中启动和暂停进程

eclipse - 逆时针在eclipse中不使用步进调试器?

java - 如何在 eclipse helios 中为断点添加多个条件?