Skip to content

Mettre en place son environnement de développement Odoo

1. Dossier de travail

1.1 Dossiers

Créer les dossiers suivants:

mkdir addons etc postgresql

1.2 Configuration d'odoo

Créer le fichier etc/odoo.conf

etc/odoo.conf
[options]
; This is the password that allows database operations:
admin_passwd = Mot_de_passe_pour_protéger_la_base_de_données
db_host = db
db_port = 5432
db_user = odoo
db_password = odoo
addons_path = /mnt/extra-addons
without_demo = True
proxy_mode = True
max_cron_threads = 1
#db_filter = ^odoo$
#list_db = False

1.3 Docker-compose

Créer le fichier docker-compose.yml:

docker-compose.yml
version: '2'
services:
db:
    image: postgres:13
    user: root
    environment:
    - POSTGRES_PASSWORD=odoo
    - POSTGRES_USER=odoo
    - POSTGRES_DB=postgres
    restart: always             # run as a service
    #volumes:
    #    - ./postgresql:/var/lib/postgresql/data

odoo16:
    image: odoo:16
    user: root
    depends_on:
    - db
    ports:
    - "10014:8069"
    - "20014:8072" # live chat
    tty: true
    command: --
    #    command: odoo scaffold /mnt/extra-addons/custom_module
    environment:
    - HOST=db
    - USER=odoo
    - PASSWORD=odoo
    volumes:
    #- /etc/timezone:/etc/timezone:ro
    #- /etc/localtime:/etc/localtime:ro
    # - ./entrypoint.sh:/entrypoint.sh   # if you want to install additional Python packages, uncomment this line!
    - ./addons:/mnt/extra-addons
    - ./etc:/etc/odoo
    restart: always             # run as a service

2. Configure vscode

2.1 Install vscode extensions

Go to extensions views by clicking on the square icon in the sidebar or pressing Ctrl+Shift+X .

  1. Search for "Docker" and install the one published by Microsoft.
  2. Search for "Json" and install the one published by ZainChen.

2.2 Configure task

.vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "docker-compose up",
            "type": "shell",
            "command": "docker-compose up",
            "problemMatcher": [],
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        }
    ]
}

3. Finalize installation

3.1 Access

You can now deploy odoo by clicking on Terminal > Run Task > docker-compose up.

Your instance is now available at http://localhost:10014

3.2 Configure

First time, you are redirected to database configuration.

You need to use the master password defined in etc/odoo.conf

ScreenShot for first access to odoo instance, with a form for db configuration

Vous pouvez maintenant décommenter les 2 dernières lignes du fichier odoo.conf, et redémarrer votre instance avec docker-compose restart.

3.3 Installation des modules

Une fois les modules communautaires téléchargés dans le dossier des addons, il faut entrer dans le conteneur pour lancer l'installation des modules:

user@host:~$ docker-compose exec -u odoo web bash
odoo@odoo-container:/$ find /mnt/extra-addons/ -mindepth 1 -maxdepth 1 -type d -printf "%f," | sed -E 's/(.*),/\1/' |xargs odoo -d odoo -i