Skip to content
Home » My Blog Tutorial » Supercharge Your Odoo 17 Development: Docker Setup and VSCode Debugging Guide

Supercharge Your Odoo 17 Development: Docker Setup and VSCode Debugging Guide

debug odoo 17 docker vscode

Odoo 17 Development Docker VSCode Debugging – Are you ready to revolutionize your Odoo 17 development process? In this comprehensive guide, we’ll walk you through setting up a powerful Docker environment for Odoo 17 and show you how to leverage VSCode for efficient debugging. Let’s dive in and unlock the full potential of your Odoo development workflow!

Why Docker and VSCode for Odoo 17?

Odoo 17 Development Docker VSCode Debugging – First and foremost, Docker provides a consistent and isolated environment for Odoo development. Moreover, VSCode offers powerful debugging tools that can significantly boost your productivity. Together, they create an unbeatable combination for Odoo 17 development.

Setting Up Your Docker Environment

Prerequisites

Before we begin, ensure you have the following tools installed:

  1. Docker
  2. Git
  3. VSCode with these essential extensions:
  • Docker
  • Odoo IDE
  • Python Debugger

Step-by-Step Setup Process

1. Clone the Project

First, let’s grab the project template:

git clone https://github.com/teguhteja/docker-odoo-dev.git -b 16

2. Fetch Odoo Stubs

Next, run this script to get the odoo-stub folder:

./git-clone-odoo-stubs.sh

3. Build the Docker Image

Now, let’s build our Odoo development image:

docker build -t odoodev:17 .

4. Launch Docker Compose

Then, start the Odoo 17 and PostgreSQL 16 containers:

docker compose up -d

5. Add Your Custom Addons

Finally, place your addons in the custom-addons folder. After adding new addons, restart the Docker stack using:

docker compose restart odoo-dev

Debugging Odoo 17 with VSCode

Setting Up the Debugger

  1. First, open your project in VSCode.
  2. Then, set breakpoints in your source code.
  3. Next, ensure your launch.json file includes "justMyCode": false to debug external code.

Accessing Odoo Source Code

To debug Odoo’s core, you’ll need access to its source code. Run this command:

./docker-cp-odoo.sh

This script copies the Odoo source code from the container to your local machine.

Configuring Docker Compose for Debugging

To enable debugging of Odoo’s core, uncomment this line in your docker-compose.yml:

- ./odoo:/usr/lib/python3/dist-packages/odoo

After making changes, restart your Docker stack.

Starting the Debugger

  1. Set breakpoints in your custom addons and Odoo core code.
  2. Launch the debugger process in VSCode.
  3. Trigger the code path you want to debug in your Odoo instance.

Pro Tips for Effective Debugging

  1. Use conditional breakpoints for complex scenarios.
  2. Leverage VSCode’s watch window to monitor variable values.
  3. Utilize the debug console to execute Python code on the fly.

Troubleshooting Common Issues

Issue: Backup Failures with Docker Images

If you encounter backup failures, you may need to modify the misc.py file in your Odoo container. Here’s how:

  1. Access the container’s shell:
   docker exec -it your_odoo_container_name /bin/bash
  1. Navigate to the Odoo directory:
   cd /usr/lib/python3/dist-packages/odoo
  1. Edit the misc.py file using a text editor like nano:
   nano tools/misc.py
  1. Locate the problematic section and make necessary adjustments.
  2. Save the file and exit the editor.
  3. Restart your Odoo container:
   docker restart your_odoo_container_name

Conclusion

By leveraging Docker and VSCode for Odoo 17 development, you’re setting yourself up for success. This powerful combination provides a stable environment, efficient debugging tools, and a streamlined workflow. Start implementing these techniques today and watch your Odoo development productivity soar!

Ready to take your Odoo 17 development to the next level? Check out our advanced Odoo courses and become an Odoo development pro!


Discover more from teguhteja.id

Subscribe to get the latest posts sent to your email.

Leave a Reply

Optimized by Optimole
WP Twitter Auto Publish Powered By : XYZScripts.com

Discover more from teguhteja.id

Subscribe now to keep reading and get access to the full archive.

Continue reading