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

  • How can the current build context directory be referenced inside of a Dockerfile?
  • how force deleting docker image affects existing containers using it
  • ECS network host mode and links = CannotCreateContainerError: Container already exists
  • Docker-compose network link
  • How to quickly show policies of all docker containers
  • docker status “Restating” forever
  • {
        '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.

  • Volume on host - permission denied for Postgres (Mac OS)
  • Docker run cannot publish port range despite netstat indicates that ports are available
  • Not enough entropy to support /dev/random in docker containers running in boot2docker
  • docker-compose volumes with a custom docker file
  • how to modify files in a container using a script
  • Gitlab cross project dependency - python
  • 4 Solutions collect form web for “Odoo development on Docker”

    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)

    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.

    • Here the quick guide on module creation.
    • Here the Detail Guide on API and framework.

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

    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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.