Skip to content

Instantly share code, notes, and snippets.

@kerbrose
Last active March 29, 2024 19:15
Show Gist options
  • Save kerbrose/e646aaf9daece42b46091e2ca0eb55d0 to your computer and use it in GitHub Desktop.
Save kerbrose/e646aaf9daece42b46091e2ca0eb55d0 to your computer and use it in GitHub Desktop.
switching to debugpy
{
// 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": "Odoo: Attach",
"type": "python",
"request": "attach",
"port": 8879,
"debugServer": 8888,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/mnt/extra-addons",
}
],
"logToFile": true
//"preLaunchTask": "init docker",
//"postDebugTask": "stop docker"
}
]
}
//docker-compose run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m ptvsd --host 0.0.0.0 --port 3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
//docker-compose run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m ptvsd --host 0.0.0.0 --port 3001 /usr/bin/odoo --test-enable --db_user=odoo --db_host=db --db_password=odoo
//docker-compose run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "init docker",
"type": "shell",
"command": "docker-compose run -d -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m ptvsd --host 0.0.0.0 --port 3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo"
},
{
"label": "stop docker",
"type": "shell",
"command": "docker rm -f $(docker ps -a -q --filter ancestor=docker.core-bpo.net/dev/odoo/digital_wellnez --format='{{.ID}}')",
}
]
}
@ZERO20
Copy link

ZERO20 commented May 11, 2020

hi can you help me please I am running odoo with docker-compose, is there a way to add the commands in the yml file? I am currently installing pip3 install debugpy with docker exec and then run the command python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo -w odoo -r odoo --db_host db -p 5432

when executing it in vsc it is marked in orange and it tells me that the points are on a file that does not exist, please if you can help me I would greatly appreciate it since the debug is something that helps a lot
Captura de pantalla_2020-05-11_12-50-45
code

docker-compose.txt

@kerbrose
Copy link
Author

@ZERO20

make sure that you mapped the remoteRoot correctly. I mean that in your docker image the path maybe different than /mnt/extra-addons.

@amefu
Copy link

amefu commented Jul 17, 2020

Hi can you help me ? I don't where to put this launch.json, if it goes in a folder inside the odoo image or in my local folder where i have my docker compose and my configs

imagen

imagen

if its inside the container where should i put it ?

@kerbrose
Copy link
Author

kerbrose commented Nov 1, 2020

@atomixm
this is relative per project directory. it should be inside a folder as following

.vscode/launch.json

@Serguipe28
Copy link

@kerbrose Can you pass an example docker-compose folder?

@mathisgauthey
Copy link

Hey there, I'm currently trying to setup a Odoo dev environment, but I can't seem to find out how to have the Odoo source file on my host machine with a mapped folder in my container.

Either I didn't clone the Odoo get and it's telling me Odoo has no attribute cli.
Or I did a clone in the host mapped folder and I get another error at launch.

What I'm missing is from it :

  • An auto complete using VSCode Odoo IDE extension, it need an Odoo source in the project and can't find one
  • An easier restarting of the server using F5, Ctrl+Shift+F5

I see you did manage to do it, I hope there's a way for Odoo 17 👌

@kerbrose
Copy link
Author

@mathisgauthey
in my local developement environement, I make 2 files, a workspace file and a launcher file for each project/company. my directory structure is like the following:

odoo/
odoo_enterprise/
<Project Folder>/

for the first time I open the using code command eg. I create a playground_odoo_17 folder and I open it using vscode command:

code playground_odoo_17

once vscode opens, I right click on vscode explorer and I click on Add Folder to Workspace to add the 2 odoo folders, and

20240330_01_adding_workspace

later on I save the workspace folder in path <Project Folder>/.vscode/

20240330_02_adding_workspace

finally I save the following launcher file in the same path <Project Folder>/.vscode/

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Odoo 17",
            "program": "${workspaceFolder}/../odoo_17/odoo-bin",
            "type": "python",
            "request": "launch",
            "args": [
                "--config",
                "${workspaceFolder}/.config/odoo.cfg",
                "--db-filter",
                "^17.*$",
                // "-u",
                // "pos_customization",
                // "--dev",
                // "xml,qweb"
                // "--save",
                // "--stop-after-init"
            ],
            "justMyCode": false,
        }
    ]
}

@mathisgauthey
Copy link

@mathisgauthey in my local developement environement, I make 2 files, a workspace file and a launcher file for each project/company. my directory structure is like the following:

odoo/
odoo_enterprise/
<Project Folder>/

for the first time I open the using code command eg. I create a playground_odoo_17 folder and I open it using vscode command:

code playground_odoo_17

once vscode opens, I right click on vscode explorer and I click on Add Folder to Workspace to add the 2 odoo folders, and

20240330_01_adding_workspace

later on I save the workspace folder in path <Project Folder>/.vscode/

20240330_02_adding_workspace

finally I save the following launcher file in the same path <Project Folder>/.vscode/

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Odoo 17",
            "program": "${workspaceFolder}/../odoo_17/odoo-bin",
            "type": "python",
            "request": "launch",
            "args": [
                "--config",
                "${workspaceFolder}/.config/odoo.cfg",
                "--db-filter",
                "^17.*$",
                // "-u",
                // "pos_customization",
                // "--dev",
                // "xml,qweb"
                // "--save",
                // "--stop-after-init"
            ],
            "justMyCode": false,
        }
    ]
}

Hey there, thanks for the input !

The issue is that it doesn't seem to allow for an easy debugging process using Odoo source code alongside custom modules. Here's what I tried, without success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment