Ihsan Nurul Iman
Ihsan Nurul Iman

Reputation: 13

VS Code's Python Debugger doesn't hit the breakpoint for Odoo 10

I use VS Code extension Python version 2.2x, Python interpreter version 2.7x, and use Odoo 10 of the latest version. I'm using WSL with Ubuntu 18.4 LTS.

I cannot debug the custom modules my company creates. I've specified the module's path in the argument, and it does run but it's not breaking at the breakpoints I specified.

Here's my launch.json:

 {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "/home/ihsansfd/odoo/odoo-bin",
        "python": "/usr/bin/python",
        "args": [
            "--db_port=5434",
            "--addons-path=/mnt/d/kuliah/odoo/repo/MUK/base,/mnt/d/kuliah/odoo/repo/MUK/core,/mnt/d/kuliah/odoo/repo/MUK/modifier",
        ],
        "console": "integratedTerminal",
        "justMyCode": true
    },

Aside from request launch, I also tried attach and using a pip library debugpy for that but it's still only running without debugging.

I am really sure that it should hit the breakpoint because I've set a print statement there and it printed!

Any help would be appreciated. If you need any further detail please do ask.

Upvotes: 0

Views: 1411

Answers (1)

Aaron Beaudoin
Aaron Beaudoin

Reputation: 587

Although you mentioned you've tried using attach with debugpy, I'm sharing my configuration since attach and debugpy is what I use every day without any issues.

Here is the shell command I use to run odoo via debugpy.

python3 /debug/debugpy --listen 0.0.0.0:5678 <odoo-bin-path> <odoo-args>

Change python3 to just python for your use case. Also change 0.0.0.0:5678 to whatever you need as well. I like to run Odoo inside a Docker container, and that's also the reason why I prefer to simply attach to the process rather than launching it right from VS Code.

I installed debugpy to /debug/debugpy using this command:

python3 -m pip install debugpy -t /debug

Here is the launch configuration I use in my launch.json:

{
  "name": "Attach to Odoo",
  "type": "python",
  "justMyCode": false,
  "request": "attach",
  "host": "localhost",
  "port": 5678,
  "pathMappings": [
    ...
    I need path mapping for my setup to map the
    location of my local Odoo source code directory
    to the location of the Odoo source code directory
    inside of the Docker container. Depending on your
    setup, you might be able to just skip this option.
    ...
  ]
}

Hopefully this helps!

Upvotes: 1

Related Questions