Skip to Content
Menu
This question has been flagged
2 Replies
18030 Views

Hi there!

I ´m developing a custom module on my local machine. I am using Docker Odoo Container and Visual Studio Code . So, guys... How to debug the Odoo code (Custom Module Code and Main Source Code) using Docker and Vistual Studio Code? I got part of the solution but looks like is missing something.

I did some changes on my launch.json, dockerfile and docker-compose files. So... I don´t know what to do now..

---------------------

My dockerfile:

 FROM debian:stretch

LABEL maintainer="Odoo S.A. <info@odoo.com>"


# Generate locale C.UTF-8 for postgres and general locale data

ENV LANG C.UTF-8


# Install some deps, lessc and less-plugin-clean-css, and wkhtmltopdf

RUN set -x; \

        apt-get update \

        && apt-get install -y --no-install-recommends \

            ca-certificates \

            curl \

            dirmngr \

            fonts-noto-cjk \

            gnupg \

            libssl1.0-dev \

            node-less \

            pkg-config \

            python3-pip \

            python3-pyldap \

            python3-qrcode \

            python3-renderpm \

            python3-setuptools \

            python3-vobject \

            python3-watchdog \

            xz-utils \

            #libssl-dev \

            #libxml2-dev \

            #libxmlsec1-dev \

        && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb \

        && echo '7e35a63f9db14f93ec7feeb0fce76b30c08f2057 wkhtmltox.deb' | sha1sum -c - \

        && dpkg --force-depends -i wkhtmltox.deb\

        && apt-get -y install -f --no-install-recommends \

        && rm -rf /var/lib/apt/lists/* wkhtmltox.deb


# install latest postgresql-client

RUN set -x; \

        echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' > etc/apt/sources.list.d/pgdg.list \

        && export GNUPGHOME="$(mktemp -d)" \

        && repokey='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' \

        && gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \

        && gpg --armor --export "${repokey}" | apt-key add - \

        && gpgconf --kill all \

        && rm -rf "$GNUPGHOME" \

        && apt-get update  \

        && apt-get install -y postgresql-client \

        && rm -rf /var/lib/apt/lists/*


# Install rtlcss (on Debian stretch)

RUN set -x;\

    echo "deb http://deb.nodesource.com/node_8.x stretch main" > /etc/apt/sources.list.d/nodesource.list \

    && export GNUPGHOME="$(mktemp -d)" \

    && repokey='9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280' \

    && gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "${repokey}" \

    && gpg --armor --export "${repokey}" | apt-key add - \

    && gpgconf --kill all \

    && rm -rf "$GNUPGHOME" \

    && apt-get update \

    && apt-get install -y nodejs \

    && npm install -g rtlcss \

    && rm -rf /var/lib/apt/lists/*


# Install Odoo

ENV ODOO_VERSION 12.0

ARG ODOO_RELEASE=20190424

ARG ODOO_SHA=3885be6791b9b8c2a74115299e57213c71db4363

RUN set -x; \

        curl -o odoo.deb -sSL http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/odoo_${ODOO_VERSION}.${ODOO_RELEASE}_all.deb \

        && echo "${ODOO_SHA} odoo.deb" | sha1sum -c - \

        && dpkg --force-depends -i odoo.deb \

        && apt-get update \

        && apt-get -y install -f --no-install-recommends \

        && rm -rf /var/lib/apt/lists/* odoo.deb


# Copy entrypoint script and Odoo configuration file

RUN pip3 install num2words xlwt

COPY ./entrypoint.sh /

COPY ./config/odoo.conf /etc/odoo/

RUN chown odoo /etc/odoo/odoo.conf


# Mount /var/lib/odoo to allow restoring filestore and /mnt/extra-addons for users addons

RUN mkdir -p /mnt/extra-addons \

        && chown -R odoo /mnt/extra-addons

VOLUME ["/var/lib/odoo", "/mnt/extra-addons"]


#Install Brazil Location Depences


RUN pip3 install wheel

RUN pip3 install pillow==3.4.2

RUN pip3 install ofxparse==0.16

RUN pip3 install suds-jurko-requests

RUN pip3 install pytrustnfe3>=0.10.0

RUN pip3 install python3-cnab

RUN pip3 install python3-boleto

#RUN pip3 install xmlsec

#RUN pip3 install lxml==4.2.3

RUN pip3 install pycnab240


# Expose Odoo services - 5858 to debug

EXPOSE 8069 8071 5858


# Set the default config file

ENV ODOO_RC /etc/odoo/odoo.conf


# Set default user when running the container

USER odoo


ENTRYPOINT ["/entrypoint.sh"]

CMD ["odoo"]

--------------------------

My docker compose file: 

version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile-dev
image: odoo:12.0
depends_on:
- db
ports:
- "8069:8069"
- "5858:5858"
volumes:
- odoo-web-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
db:
image: postgres:10
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata

volumes:
odoo-web-data:
odoo-db-data:
Avatar
Discard

Did you work it out? I have the same problem.

Best Answer

Well, I guess there is better way that there is no need to add code to odoo itself

https://gist.github.com/kerbrose/e646aaf9daece42b46091e2ca0eb55d0

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Odoo: Attach",
            "type": "python",
            "request": "attach",
            "port": 8879,
            "debugServer": 8888,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/mnt/extra-addons", //path to custom addons inside docker
                },
                {
                    "localRoot": "/dev/odoo", //odoo source code
                    "remoteRoot": "/odoo",    //path to source inside docker
                }
            ],
            "logToFile": true
            //"preLaunchTask": "init docker",
            //"postDebugTask": "stop docker"
        }
    ]
}

please note that your docker.dev file should include

RUN pip3 install -U debugpy

then you will be running the debugger not odoo as
docker run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
or
docker-compose run --rm -p 8888:3001 -p 8879:8069 odoo /usr/bin/python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
Avatar
Discard
Related Posts Replies Views Activity
4
Dec 23
41253
1
Jan 23
2143
1
Mar 24
4427
1
Feb 21
1623
0
Dec 20
3046