<p>是的,您甚至可以使用VSCode调试Odoo:</p>
<p>首先,需要在VSCode中安装<a href="https://marketplace.visualstudio.com/items?itemName=ms-python.python" rel="nofollow noreferrer"><strong>Python Extension</strong></a>。</p>
<p>将安装Odoo的文件夹添加到当前项目中。您可以使用功能<a href="https://code.visualstudio.com/docs/editor/multi-root-workspaces" rel="nofollow noreferrer"><strong>Multiroot Workspaces</strong></a>。我认为在这种情况下很方便:在一个文件夹中打开项目模块,在另一个文件夹中打开Odoo</p>
<p>然后,如果您想开始调试,只需单击Debug按钮,然后单击侧边栏顶部的控制盘。文件<code>launch.json</code>将打开,您只需将此元素添加到底部。</p>
<pre class="lang-js prettyprint-override"><code>{
"name": "Python: Odoo",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"console": "externalTerminal",
"program": "${workspaceRoot}/odoo_path/odoo.py",
"args": [
"--config=/odoo_config_path/.odoo_8.conf",
],
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"RedirectOutput"
]
}
</code></pre>
<p>添加后,您就可以在VSCode下运行Odoo了。有关启动配置的详细信息<a href="https://code.visualstudio.com/docs/editor/debugging#_launch-configurations" rel="nofollow noreferrer">click here</a></p>
<p>现在可以像往常一样创建断点。您也可以使用调试器控制台。如果像我一样使用属性:<code>"console": "externalTerminal"</code>,则可以同时在外部控制台中显示日志</p>
<p><a href="https://i.stack.imgur.com/5RMZg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5RMZg.png" alt="enter image description here"/></a></p>
<p><strong>注意</strong>:如果只想运行odoo,可以在VSCode中使用集成控制台</p>
<p><strong>注意2</strong>:我建议也安装<a href="https://marketplace.visualstudio.com/items?itemName=jeffery9.odoo-snippets" rel="nofollow noreferrer">the Odoo Snippets extension</a>。</p>