Skip to content
Home » My Blog Tutorial » Debug Odoo Docker VSCode

Debug Odoo Docker VSCode

docker odoo vscode

Remote Debugging Odoo (short version)

Introduction Debug Odoo Docker VSCode

Welcome to this guide on Debug VSCode capabilities using Odoo Docker extensions and remote debugging. We aim to make your coding experience more efficient and enjoyable.

Preparation

First, ensure you have Visual Studio Code and Docker on your PC. Start by cloning the necessary source code from GitHub:

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

This GitHub repository, forked from mjavint/docker-odoo-dev, is perfect for Odoo development using Docker in Visual Studio Code. It includes essential files and configurations for setting up an Odoo development environment.

Key Features of the Repository:

  • VSCode Integration: Steps for installing VSCode and Python and Odoo extensions.
  • Workspace Setup: How to create a workspace with Odoo source code.
  • Python Type Checking: Using pyrightconfig.json for Python type checking.
  • Docker Image Compilation: Building a Docker image for Odoo development.
  • Environment Setup: Setting up variables in the .env file.
  • Debug Configuration: Configuring VSCode for efficient Odoo app debugging.

Installing Extensions

To set up your VSCode for Python and Odoo development:

  1. Open VSCode and go to the Extensions panel.
  2. Install the Python extension for Python support.
  3. Add the VSCode Odoo Extension for Odoo-specific features.
  4. Optionally, install Odoo Snippets for quick code snippets.

Configuring Docker

The first phase in Debug Odoo Docker in VSCode configuration focuses on building a Docker image. This image includes Odoo and debugpy, a Python debugging library. Modify the requirement.txt file in the Docker image to add debugpy, embedding essential debugging tools into the Docker environment.

FROM odoo:16.0
USER root
COPY ./requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
RUN rm /requirements.txt

This Dockerfile creates an image based on Odoo 16.0. It sets the user as ‘root’ and installs Python packages from requirements.txt, which includes debugpy and pydevd-odoo.

Setting Up VSCode

The pyrightconfig.json file is crucial for Pyright, a Python static analysis tool. It contains settings for module paths and stubs, enhancing Python code analysis.

Remote Debugging Setup

Setting up Docker containers with Docker compose is crucial for running multi-container Docker applications. The .env file in the project folder contains variables used in docker-compose.yaml, defining the Odoo environment and PostgreSQL database settings.

This configuration sets up the Odoo environment and PostgreSQL database in Docker containers, ensuring a seamless development process.

Running and Debugging

  1. Start Docker Compose: Run docker compose-up in the terminal or use VSCode’s extension explorer.
  2. Create Containers: Docker will create containers for Odoo 16 and PostgreSQL 15.
  3. Run Containers: Use docker run -t -d or VSCode’s Docker extension.
  4. View Logs: Check logs using the Docker extension.
  5. Access Odoo: Open localhost:8016 in your browser to set up the Odoo database.
  6. Database Setup: Follow the prompts to create and configure your Odoo database.
  7. Debugging: Start debugging in VSCode and install the accounting process.

Conclusion

This tutorial helps you leverage Docker and remote debugging in Visual Studio Code. Explore these settings to unlock your IDE’s full potential.

Final Thoughts

By following this guide, you can enhance your Visual Studio Code, making it a more powerful tool for software development.


Discover more from teguhteja.id

Subscribe to get the latest posts sent to your email.

1 thought on “Debug Odoo Docker VSCode”

  1. Pingback: Odoo VSCode Ubuntu : Setting Up - teguhteja.id

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