DEV Community

Discussion on: Clean Odoo debugging

Collapse
 
afromonkey profile image
Moisés Alejandro Navarro Presas

Do you know a practical way to do this but using Docker (Odoo official image)?

Collapse
 
alfadil profile image
Alfadil mustafa

yes of course:

  1. you must know how to run odoo image .
  2. go to odoo.com/page/download, And download the odoo source (for the version you want)
  3. in the download directory go to addons/init.py and add
try:
    import ptvsd
    ptvsd.enable_attach(address=('0.0.0.0', 3000))
except:
    pass
Enter fullscreen mode Exit fullscreen mode
  1. run the docker image with the source you just downloaded as a volume like :
-v path/to/downloaded/source/:/usr/lib/python3/dist-packages/odoo
Enter fullscreen mode Exit fullscreen mode
  1. after that run
docker exec -it container_name pip3 install ptvsd
Enter fullscreen mode Exit fullscreen mode

and then restart the container

docker restart container_name
Enter fullscreen mode Exit fullscreen mode

after that go to launch.json and change the host and port according to what you set in the init file

Collapse
 
afromonkey profile image
Moisés Alejandro Navarro Presas

But the IP of the container will change on every "recreation", isn't?

Thread Thread
 
alfadil profile image
Alfadil mustafa

you are right
so you can expose the port at the run step

Thread Thread
 
afromonkey profile image
Moisés Alejandro Navarro Presas

Sounds good, the only problem is that I'm used to have multiple independent projects (like 5 at the same time), and assign manually an IP for each of them doesn't feel right.

Anyway, thanks for your replies :)

Thread Thread
 
alfadil profile image
Alfadil mustafa

if you exposed the port at run step and used launch.json for each project, you can use localhost but with different port in each project according to the configuration .
you are welcome :)