Youssef Bouhjira
Youssef Bouhjira

Reputation: 1629

Odoo development on Docker

I'm trying to use docker for odoo module developement. I have the following docker-compose.yml file

db:
  image: postgres
  environment:
    POSTGRES_USER: odoo
    POSTGRES_PASSWORD: odoo
  volumes:
    - data:/var/lib/postgresql/data/

odoo:
  image: odoo
  links:
    - db:db
  ports:
    - "127.0.0.1:8069:8069"
  volumes:
    - extra-addons:/mnt/extra-addons
  command: -- --update=tutorial

The module contains only an __openerp__.py file but odoo doesn't show the changes I make to it even with --update=tutorial option

{
    'name': "tutorial",

    'summary': """Hello world!!""",

    'description': """
        This is the new description
    """,

    'author': "ybouhjira",
    'website': "ybouhjira.com",

    'category': 'Technical Settings',
    'version': '0.1',
    'depends': ["base"],
}

this file is in a folder named tutorial located in extra-addons, and I tried stop and starting the containers even removing and recreating them.

Upvotes: 9

Views: 8991

Answers (8)

Dylan Ngo
Dylan Ngo

Reputation: 21

My docker-compose file support run Odoo 15 on Docker:

version: '3'

services:
  postgres:
    image: postgres:13
    container_name: postgres
    restart: always
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      PGDATA: /var/lib/postgresql/data
    volumes:
      - ./data/postgres:/var/lib/postgresql/data

  odoo:
    image: odoo:15
    container_name: odoo
    restart: always
    depends_on:
      - postgres
    ports:
      - "8069:8069"
      - "8072:8072"
    environment:
      HOST: postgres
      USER: ${POSTGRES_USER}
      PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - ./etc/odoo:/etc/odoo
      - ./data/addons:/mnt/extra-addons
      - ./data/odoo:/var/lib/odoo

Upvotes: 0

rudi Ladeon
rudi Ladeon

Reputation: 693

First of all create a directory with the docker-compose.yml file and these directories:

/addons
/volumes/odoo/sessions
/volumes/odoo/filestore
/docker-compose.yml

Put this code in your docker-compose.yml file :

version: '3'
services:
  web:
    image: odoo:12.0
    depends_on:
     - db
    ports:
     - "8069:8069"
    volumes:
     - odoo-web-data:/var/lib/odoo
     - ./volumes/odoo/filestore:/opt/odoo/data/filestore
     - ./volumes/odoo/sessions:/opt/odoo/data/sessions
     - ./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:

Then in a terminal write for build your environnement:

docker-compose up
docker-compse start or docker-compose stop 

If you want to add custom module , just put it in addons directory then clic on update app list in App module, restart docker , after this disable all filters in search bar. Normally if you write module name in search bar your custom module will show below.

Upvotes: 0

龙美凤
龙美凤

Reputation: 11

this fix my problem, we need create "odoo.conf" in ./config

[options]
addons_path = /mnt/extra-addons,/usr/lib/python2.7/dist- packages/odoo/addons
data_dir = /var/lib/odoo
auto_reload = True

Upvotes: 1

Daniel Blanco
Daniel Blanco

Reputation: 527

Take into account that the description, icons, and version inside the manifest, not always change innmediatly. Try to shift f5 your browser, but this is not so relevant when you are developing.

Besides having as a minimum, the manifest, and init.py file, if you are using docker-compose, I recommend having a script to put down, remove and recreate your container.

./doeall

cat doeall

#!/bin/sh
docker-compose down
docker-compose rm
docker-compose up -d
docker-compose logs -f

For developing purposes, is also convenient to have db in a separated docker-compose.yml, so that you can reuse the same db container for several odoo installations.

Take a look to my docker-compose for multi-instances here:

https://github.com/bmya/odoo-docker-compose/tree/multi

anyway, if you still want to use Postgres as db together in the same docker-compose file, you have it in this other branch:

https://github.com/bmya/odoo-docker-compose/blob/uni/docker-compose.yml

Again, regarding your module: The important thing when you are writing code is: When you change something in the methods in python code, just restart the server. When you change something in the model inside python restart the server and reinstall. When you change data files (views, data, etc) just reinstall the module in order to update the data files.

Upvotes: 1

Lesser Jank
Lesser Jank

Reputation: 381

You have to add own config file. first in docker-compose.yml mount /etc/odoo

odoo:
 image: odoo
 links:
  - db:db
 ports:
  - "127.0.0.1:8069:8069"
 volumes:
  - extra-addons:/mnt/extra-addons
  - ./config:/etc/odoo

Then create "odoo.conf" in ./config and add configuration options like below.

[options]
addons_path = /mnt/extra-addons,/usr/lib/python2.7/dist- packages/odoo/addons
data_dir = /var/lib/odoo
auto_reload = True

restart odoo, go to debug mode then apps->update module list

If still not works, then check access rights on addons directories and check if group and others can read them

Upvotes: 6

azyzy
azyzy

Reputation: 11

The --update option requires -d specifying the database name Odoo CLI doc

Upvotes: 1

Vorex
Vorex

Reputation: 61

Like shodowsjedi already said, you need to create a __init__.py file (see module structure : https://www.odoo.com/documentation/8.0/howtos/backend.html#module-structure ).

Also, check permissions in your odoo containers, your files in the odoo volume will have uid and gid of your system (the host) in the container (that can be associated to a different user). To check this you can use docker exec :

docker exec docker_odoo_1 ls -la /mnt/extra-addons

If you don't know the docker name of your container you can retrieve it by using :

docker-compose ps

Last and probably the most important one, check odoo logs by using :

docker-compose logs

and update your module in the configuration page of Odoo (or at the startup of the server)

Upvotes: 6

ifixthat
ifixthat

Reputation: 6295

To create new module you need more then Odoo Manifest file __openerp__.py file you also need Python Descriptor file __init__.py as minimal structure, of course you need more then two file but that minimal to module to exists. Once you create a module on existing database you need call Update module List under setting to load your module correctly and then you will be able to install it.

Upvotes: 2

Related Questions