i want set red point on any line and see debug mod
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
then you will be running the debugger not odoo as
https://dev.to/kerbrose/how-to-remote-debugging-odoo-docker-images-python-based-framework-4o2h has a more up to date answer.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
4
Dec 19
|
9641 | ||
|
0
Nov 23
|
532 | ||
|
2
Sep 23
|
623 | ||
|
0
Sep 21
|
2372 | ||
|
0
Feb 21
|
3983 |