使用vscode调试odoo

本文使用的系统环境为ubuntu 18.04,odoo版本为odoo11,虚拟环境使用Virtualenv。
  1. 配置Virtual Environments的路径。打开File -> Preferences -> Settings, 在右侧的USER SETTINGS中添加 "python.venvPath": "~/env","~/env"为Virtual Environments路径。

    {
        "python.venvPath": "~/env",
    }
    复制代码
  2. 配置launch.json。打开Debug -> Open Configurations, 选择python,${workspaceFolder}为工作目录,-c -u -d 等参数均可在args中填写。

    {
        "name": "Odoo",
        "type": "python",
        "request": "launch",
        "program": "${workspaceFolder}/odoo/odoo-bin",
        "args": [
            "-c",
            "${workspaceFolder}/odoo.conf"
        ]
    }
    复制代码
  3. 用vscode打开整个odoo工作目录会有一个警告 “Visual Studio Code is unable to watch for file changes in this large workspace”。如果不处理,debug会出现问题。这里可以参照vscode官网给出的解决方案

    When you see this notification, it indicates that the VS Code file watcher is running out of handles because the workspace is large and contains many files. The current limit can be viewed by running:

    cat /proc/sys/fs/inotify/max_user_watches
    复制代码

    The limit can be increased to its maximum by editing /etc/sysctl.conf and adding this line to the end of the file:

    fs.inotify.max_user_watches=524288
    复制代码

    The new value can then be loaded in by running sudo sysctl -p. Note that Arch Linux works a little differently, view this page for advice.

  4. 如果安装了pylint,代码会有一堆pylint的错误提示,但是不影响odoo运行。如果不爽的话可以卸载pylint,也可以在USER SETTINGS中添加以下代码,将pylint的enable设置为false。

    "python.linting.enabled": false,
    复制代码
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值