콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
6 답글
35401 화면

i want set red point on any line and see debug mod

아바타
취소
베스트 답변

You can use the following manual to configure VSCode for debugging Odoo using Docker:

https://cetmix.com/blog/cetmix-blog-2/odoo-development-using-visual-studio-code-and-docker-1

아바타
취소
베스트 답변

Hello friends, try the configuration that was marked as an answer but I get "Failler to attach (connect ECONNREFUSED 172.18.0.3:3000)" inside the container according to point 3 but with the ip of the container and copy the json to my debug file and can anything help me ??

아바타
취소
작성자

Hi Edgar, did you run first container and after attached debugger? if no try this, if yes give me your launch.json and docker inspect result

{

"version": "0.2.0",

"configurations": [

{

"name": "Odoo: Attach",

"type": "python",

"request": "attach",

"port": 8069,

"debugServer": 8888,

"host": "localhost",

"pathMappings": [

{

"localRoot": "${workspaceFolder}/addons",

"remoteRoot": "/mnt/extra-addons", //path to custom addons inside docker

}

],

"logToFile": true

}

]

}

베스트 답변


set the following configurations in launch.json (Menu: Debug > Add Configuration.. ) of visual studio code
start odoo from Debug >Strat Debugging 

"configurations": [{
   "name": "Python: Odoo",
   "type": "python",
   "request": "launch",
   "program": "${workspaceFolder}/workspace/odoo-bin",
   "args": ["start", "--database=12.0", "--db-filter=12.0", "--addons-path=workspace/addons,enterprise"],
},
]​
​Note: change path according to your working directory.

I don't know how to set up it for a docker container.

아바타
취소
작성자 베스트 답변

steps:

1) find odoo-bin file and add new lines:

import subprocess
import time
process = subprocess.Popen("hostname -I | awk '{print $BASH_ARGV}'", stdout=subprocess.PIPE, shell=True)
while process.wait():
    time.sleep(0.1)
output, err = process.communicate()
host = output.split()[-1].decode("utf-8") 
print(host)
try:
    import ptvsd
except ImportError:
    subprocess.call('pip install ptvsd --user', shell=True)
    import ptvsd
ptvsd.enable_attach(address = (host, 3000))

where host var is IP address remote, you can find it in output terminal or run next command:

docker inspect odoo_container

in my case it was 172.25.0.4

2) create new dict in launch.json:

{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 3000,
    "host": "host var value", // 172.25.0.4
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
 ]
}

3) it is all. now you can add in any place of your code "breakpoint()" and activate debug mode

and when this part of code will be called debugger will work in vscode





아바타
취소
작성자

if you using git for original odoo you can use "git update-index --assume-unchanged odoo-bin" that git dont triggering on this file

베스트 답변

Well, I guess there is better way that there is no need to add code to odoo itself

https://gist.github.com/kerbrose/e646aaf9daece42b46091e2ca0eb55d0

{
    "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", //path to custom addons inside docker
                },
                {
                    "localRoot": "/dev/odoo", //odoo source code
                    "remoteRoot": "/odoo",    //path to source inside docker
                }
            ],
            "logToFile": true
            //"preLaunchTask": "init docker",
            //"postDebugTask": "stop docker"
        }
    ]
}

please note that your docker.dev file should include

RUN pip3 install -U debugpy

then you will be running the debugger not odoo as
docker 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
or
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
아바타
취소
베스트 답변

https://dev.to/kerbrose/how-to-remote-debugging-odoo-docker-images-python-based-framework-4o2h has a more up to date answer.

아바타
취소
관련 게시물 답글 화면 활동
4
12월 19
11100
0
11월 23
1278
2
9월 23
1632
0
9월 21
3750
0
2월 21
4984