Prequistion
Debug Odoo 17 Docker VSCode – Before to do that, you already learn :
Introduction
debug odoo 17 docker vscode- In this tutorial, you will learn how to debug Odoo 17 in Docker using VSCode. By following these steps, you can set up your development environment and streamline the debugging process.
Create Necessary Folders
debug odoo docker vscode – First, you need to create the necessary folders for your project. These include the addons
, config
, and .vscode
directories.
Create the Odoo Configuration File
Next, create the odoo.conf
file in the config
folder with the following content:
addons_path = /mnt/extra-addons
admin_passwd = superadmin
csv_internal_sep = ,
data_dir = /var/lib/odoo/.local/share/Odoo
db_host = db
db_maxconn = 64
db_name = False
db_user = odoo
db_password = odoo
db_port = 5432
db_sslmode = prefer
db_template = template0
dbfilter = .*
demo = {}
email_from = False
from_filter = False
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb
http_enable = True
http_interface =
http_port = 8069
import_partial =
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 0
limit_time_real_cron = -1
list_db = True
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = info
logfile =
longpolling_port = 8072
max_cron_threads = 2
osv_memory_age_limit = False
osv_memory_count_limit = False
pg_path =
pidfile =
proxy_mode = False
reportgz = False
screencasts =
screenshots = /tmp/odoo_tests
server_wide_modules = base,web
smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_ssl_certificate_filename = False
smtp_ssl_private_key_filename = False
smtp_user = False
syslog = False
test_enable = False
test_file =
test_tags = None
transient_age_limit = 1.0
translate_modules = ['all']
unaccent = False
upgrade_path =
without_demo = False
workers = 0
Create a Custom Docker Image
Add the Dockerfile
Create a Dockerfile and add the following lines to set up your custom image:
FROM odoo:17
USER root
COPY ./requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
RUN rm /requirements.txt
Add the Requirements File
Create a requirements.txt
file to install the necessary libraries:
debugpy
pydevd-odoo
Set Up VSCode for Debugging
Create the Launch Configuration
In the .vscode
folder, create a launch.json
file with the following content to configure remote debugging:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 8890
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/addons",
"remoteRoot": "/mnt/addons-extra"
},
{
"localRoot": "${workspaceFolder}/odoo17",
"remoteRoot": "/usr/lib/python3/dist-packages/odoo"
}
],
"justMyCode": false
}
]
}
Download Odoo 17 Source
To debug Odoo, download the latest Odoo 17 source code from the Odoo nightly builds and extract it into the 17
folder.
Build and Run the Docker Image
Build the Docker Image
Run the following command to build your Docker image:
docker build -t odoodev:17.0 -f odoo17.Dockerfile .
Create Docker Compose Configuration
Create a docker-compose.yaml
file with the following content to set up your Docker services:
services:
db:
image: postgres:16
container_name: pg16
restart: "unless-stopped"
ports:
- '5432:5432'
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
volumes:
- local_pgdata:/var/lib/postgresql/data
odoo:
image: odoodev:17.0
container_name: o17-1
depends_on:
- db
ports:
- "8017:8069"
- "8888:8888"
entrypoint: /usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo -c /etc/odoo/odoo.conf
restart: "unless-stopped"
volumes:
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
- odoo-o17-data:/var/lib/odoo
volumes:
local_pgdata:
odoo-o17-data:
Run Docker Compose
Run the following command to start your Docker services:
docker compose -f docker-compose.yaml up
Debugging in VSCode
Set Breakpoints and Start Debugging
After setting up everything, open your VSCode, set breakpoints in the Odoo source code,
and start the debugging session. VSCode will connect to the Docker container and allow you to debug Odoo code.
Conclusion
By following this tutorial, you have set up a complete environment to debug Odoo 17 in Docker using VSCode. This setup helps you streamline your development process and quickly identify and fix issues.
FAQs
What are the prerequisites for this tutorial?
You need Docker, Docker Compose, and VSCode installed on your system.
Can I use a different version of Odoo?
Yes, you can use a different version by changing the Docker image in the Dockerfile and adjusting the configurations accordingly.
How do I install additional Python libraries?
Add the required libraries to the requirements.txt
file and rebuild the Docker image.
What should I do if I encounter errors?
Check the logs in the Docker container and ensure all configurations are correct. You can also consult the Odoo and Docker documentation for troubleshooting tips.
Where can I find more information?
For more details, refer to the official Odoo documentation.
Discover more from teguhteja.id
Subscribe to get the latest posts sent to your email.