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:
- Open VSCode and go to the Extensions panel.
- Install the Python extension for Python support.
- Add the VSCode Odoo Extension for Odoo-specific features.
- 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.
{
"stubPath": "C:/Users/IdaBagusTeguhTejaMur/Project/OdooProject/odoo-stubs16",
"extraPaths": [
"C:/Users/IdaBagusTeguhTejaMur/Project/DockerProject/docker-odoo-dev/odoo16",
"C:/Users/IdaBagusTeguhTejaMur/Project/DockerProject/docker-odoo-dev/odoo16/addons",
"C:/Users/IdaBagusTeguhTejaMur/Project/DockerProject/docker-odoo-dev/custom_addons"
]
}
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.
version: '3.1'
services:
web:
container_name: ${ODOO_CONTAINER_NAME}
image: odoodev:${ODOO_VERSION}
# ... (rest of the configuration)
This configuration sets up the Odoo environment and PostgreSQL database in Docker containers, ensuring a seamless development process.
Running and Debugging
- Start Docker Compose: Run
docker compose-up
in the terminal or use VSCode’s extension explorer. - Create Containers: Docker will create containers for Odoo 16 and PostgreSQL 15.
- Run Containers: Use
docker run -t -d
or VSCode’s Docker extension. - View Logs: Check logs using the Docker extension.
- Access Odoo: Open
localhost:8016
in your browser to set up the Odoo database. - Database Setup: Follow the prompts to create and configure your Odoo database.
- 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.
Pingback: Odoo VSCode Ubuntu : Setting Up - teguhteja.id