Who is this for?

Who is this for?

This guide is intended for Odoo developers who want to install the platform quickly and without issues. It’s also useful for anyone who wants to learn about the benefits of using Docker in Odoo development.

What is Odoo?

Odoo is a powerful platform for managing business operations, such as sales, accounting, and project management. It’s highly customizable and can be adapted to a wide range of industries and use cases.

What is Odoo Env?

Odoo-env is a set of easy-to-learn commands that make it simple to install and manage Odoo using Docker. With odoo-env, you can:

The odoo-env project lives on odoo-env. Any feedback is welcome, and if you like the idea, please don’t hesitate to contact me so we can work together.

If you encounter any issues, please report them on the issues page.

In conclusion, odoo-env is a powerful tool that simplifies the installation and management of Odoo using Docker. Whether you’re a seasoned Odoo developer or just getting started, odoo-env can help you save time and reduce headaches. Give it a try and see for yourself!

If you find some issues please report it to issues

Author: Jorge Obiols jorge.obiols@gmail.com

THE PROJECT, where all the install information resides.

What you need to know:

  1. The project is an odoo module.
  2. This module has an extended manifest. Odoo does not read the extended key words, then is an installable module.
  3. Odoo-env reads the manifest to know how to install the system
  4. The information it holds:

     Odoo Version: The mayor version of the "version" keyword
     env-ver: The version of the extended sintax actually v2
     config: The data to write in odoo.conf
     odoo-license: EE o CE
     port: Port where odoo docker image starts serving pages.
     git-repos: list of repositories to install
     docker-images: list of docker images to pull
    

Additionally, as a best practice, we can place all the modules required by the installation in the depends list, then the project not only serves to install but also to create an empty database with all the required modules.

It is also recommended that you never install modules from the odoo interface, you can simply add in the depends of the project and then issue a oe -u that magically do an odoo-bin –update all –stop-after-init inside the container. Then you have a documented list of installed modules.

Syntax and examples

‘git-repos’:

General syntax: [[/] [-b ]

The git-repos keyword is a list of all the repositories to install, in the simplest form you can list the url’s of the repos this way:

  'git-repos': [
    'https://github.com/OCA/account-invoicing.git',
    'https://github.com/OCA/account-financial-tools.git'
  ]

It leads to a tree like this

   sources
   ├── account-financial-tools
   └── account-invoicing

Now if you want to add this repo:

https://github.com/ingadhoc/account-invoicing.git

it has the same name as oca repo, then you need to rename it, following the git sintax. A good practice is to rename all the repos this way:

  'git-repos': [
    'https://github.com/OCA/account-invoicing.git oca-account-invoicing',
    'https://github.com/OCA/account-financial-tools.git oca-account-financial-tools'
    'https://github.com/ingadhoc/account-invoicing.git adhoc-account-invoicing'
  ]

You get this tree

   sources
   ├── oca-account-financial-tools
   ├── oca-account-invoicing
   └── adhoc-account-invoicing

Now suppose you have to add: https://github.com/ctmil/meli_oerp.git

this is a repository that contains a single module with leads to a single level. Here we can do the following

  'git-repos': [
    'https://github.com/OCA/account-invoicing.git oca-account-invoicing',
    'https://github.com/OCA/account-financial-tools.git oca-account-financial-tools',
    'https://github.com/ingadhoc/account-invoicing.git adhoc-account-invoicing',
    'https://github.com/ctmil/meli_oerp.git ctmil/meli_orp'
  ]

You get this tree

   sources
   ├── oca-account-financial-tools
   ├── oca-account-invoicing
   ├── adhoc-account-invoicing
   └── ctmil

Inside ctmil you will find meli_orp

What about branches

All right but which branches are you getting?. As a general rule:

It downloads the branches whose name is te mayor version declared in the manifest

Then if in your manifest says

    'name': 'pentecos',
    'version': '11.0.1.0.0',

Then all the repos will be from the branch 11.0

but you can override this, perhaps you want to get a repo that do not follow the best practics and are in branch master, so you can write.

    'https://github.com/ctmil/odoo_barcode.git ctmil/odoo_barcode -b master'

In this case the branch to download will be main and also as the repository is not a set of modules but is a module wa add ctmil/odoo_barcode so it is correctly inserted y our sources.

An example project:

    ##############################################################################
    #
    #    Copyright (C) 2021 jeo Software  (http://www.jeosoft.com.ar)
    #    All Rights Reserved.
    #
    #    This program is free software: you can redistribute it and/or modify
    #    it under the terms of the GNU Affero General Public License as
    #    published by the Free Software Foundation, either version 3 of the
    #    License, or (at your option) any later version.
    #
    #    This program is distributed in the hope that it will be useful,
    #    but WITHOUT ANY WARRANTY; without even the implied warranty of
    #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #    GNU Affero General Public License for more details.
    #
    #    You should have received a copy of the GNU Affero General Public License
    #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    #
    ##############################################################################

    {
        'name': 'test11',
        'version': '11.0.1.0.0',
        'category': 'Tools',
        'summary': "Test for v11 CE",
        'author': "jeo Software",
        'website': 'http://github.com/jobiols/module-repo',
        'license': 'AGPL-3',
        'depends': [
            # applications to be installed
            'sale_management',
        ],
        'installable': True,
        'application': False,

        # Here begins odoo-env manifest configuration
        # ===========================================

        # manifest version, if omitted it is backward compatible with v1 but
        # oe will show a deprecation warning
        'env-ver': '2',

        # Configuration data for odoo.conf, if ommited oe will create an odoo.conf
        # with default values and with a proper addon_path.
        'config': [

            # 'addons_path' you can not modify this is always computed looking for the
            # repositories in sources

            # 'data_dir' you can not modify this, is a fixed location inside docker odoo
            # image

            # WORKERS and MAX_CRON_WORKERS
            # If ommited it will default the calculation
            # workers = 2 per available CPU
            # max_cron_threads = 1 per available CPU
            # In DEBUG mode both are forced to Zero

                    'workers = 2',
                    'max_cron_threads = 1',

            # Number of requests a worker will process before being recycled and
            # restarted. Defaults to 8192 if ommited
                    'limit_request = 8192',

            # Maximum allowed virtual memory per worker. If the limit is exceeded,
            # the worker is killed and recycled at the end of the current request.
            # Defaults to 640MB
                    'limit_memory_soft = 2147483648',

            # Hard limit on virtual memory, any worker exceeding the limit will be
            # immediately killed without waiting for the end of the current request
            # processing. Defaults to 768MB.
                    'limit_memory_hard = 2684354560',

            # Prevents the worker from using more than CPU seconds for each request.
            # If the limit is exceeded, the worker is killed. Defaults to 60 sec.
            # In DEBUG mode it is forced to Zero meaning no timeout
                    'limit_time_cpu = 60',

            # Prevents the worker from taking longer than seconds to process a request.
            # If the limit is exceeded, the worker is killed.
            # Defaults to 120.
            # Differs from --limit-time-cpu in that this is a "wall time" limit
            # including e.g. SQL queries.
            # In DEBUG mode it is forced to Zero meaning no timeout
                    'limit_time_real = 120',

            # default CSV separator for import and export
                    'csv_internal_sep = ,',

            # disable loading demo data for modules to be installed
                    'without_demo = False',

            # Comma-separated list of server-wide modules, there are modules loaded
            # automatically even if you do not create any database.
                    'server_wide_modules = base,web',

            # Filter listed database REGEXP
                    'dbfilter =',

            # Master password for database
                     'admin_passwd = my-admin-superpassword',

            # other configuration parameters
                    'db_maxconn = 64',
                    'db_name = False',
                    'db_password = odoo',
                    'db_port = 5432',
                    'db_sslmode = prefer',
                    'db_template = template0',
                    'db_user = odoo',
                    'demo = {}',
                    'email_from = False',
                    'geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb',
                    'http_enable = True',
                    'http_interface =',
                    'http_port = 8069',
                    'limit_time_real_cron = -1',
                    'list_db = True',
                    'log_db = False',
                    'log_db_level = warning',
                    'log_handler = :INFO',
                    'log_level = info',
                    'logfile = /dev/pts/0',
                    'osv_memory_age_limit = 1.0',
                    'osv_memory_count_limit = False',
                    'pg_path =',
                    'proxy_mode = False',
                    'reportgz = False',
                    'screencasts =',
                    'screenshots = /tmp/odoo_tests',
                    'smtp_password = False',
                    'smtp_port = 25',
                    'smtp_server = localhost',
                    'smtp_ssl = False',
                    'smtp_user = False',
                    'syslog = False',
                    'test_enable = False',
                    'test_file =',
                    'test_tags = None',
                    "translate_modules = ['all']",
                    'unaccent = False',
                    'upgrade_path =',
        ],

        # if ommited it defaults to CE
        'odoo-license': 'CE',

        # Production Server (change suelos13 and ec2-user for your data)
        # suelos13 is the alias you set in .ssh/config
        # i.e. you can access the server typing ssh suelos13
        # ec2-user is the user who is accessing the server, then when you perform a
        # oe --restore --from-prod
        # the backup will be transferred from server to your local with scp
        'prod_server': 'ec2-user@suelos13',

        # Port where odoo docker image starts serving pages if ommited defaults to 8069
        'port': '8069',

        # repositories to be installed in sources/
        # syntax:
        #
        #  "https://[github.com|gitlab.com|bitbucket.org/]/user/repo repo-dir -b branch"
        #  "git@[github.com|gitlab.com|bitbucket.org/]/user/repo repo-dir -b branch"
        #
        #   if branch is ommited it defaults to module name's mayor version
        #   if repo-dir if ommited it defaults to repo name
        #
        #   examples:
        #   'https://github.com/oca/web.git',
        #   'https://github.com/oca/web.git oca-web',
        #   'https://github.com/oca/web.git oca-web -b 11.0',
        #   'git@github.com/oca/web.git oca-web -b 11.0',
        #
        # note: in the last example for ssh protocol you have to use a SSH key

        # git-repos Syntax
        # <repo> [<directory>] [-b <branch>]
        'git-repos': [
            'https://github.com/jobiols/cl-test.git cl-test -b 11.0',
            'git@github.com:jobiols/odoo-uml.git -b 11.0',

            'https://github.com/jobiols/odoo-addons.git',
            'https://github.com/ingadhoc/odoo-argentina.git ingadhoc-odoo-argentina',
            'https://github.com/ingadhoc/account-financial-tools.git',
            'https://github.com/ingadhoc/account-payment.git',
            'https://github.com/ingadhoc/miscellaneous.git',
            'https://github.com/ingadhoc/argentina-reporting.git',
            'https://github.com/ingadhoc/reporting-engine.git',
            'https://github.com/ingadhoc/aeroo_reports.git',
        ],

        # Docker images to be used in this deployment
        # syntax: <image-name> <NAME[:TAG|@DIGEST]>
        'docker-images': [
            'odoo jobiols/odoo-jeo:11.0',
            'postgres postgres:10.1-alpine',
            'nginx nginx'
        ]
    }

Where are the images?

The images for all odoo versions from 8 to 16 version community are hosted in docker

And the dockerfiles to create those images are in github

You are encouraged to fork this and make your own images, or to use it freely

THE MAGIC BEGINS, From a fresh VPS to an installed odoo system

Start fresh, this example was build with Ubuntu Server 20.04 LTS

# start by upgrading the system
sudo apt update && sudo apt upgrade -y

# check if python 3 is installed
python3 -V

# if not installed do it
sudo apt install python3 -y

# install distutils
sudo apt install python3-distutils -y

# install pip
curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py
rm get-pip.py

# test pip
pip -V

# install odoo-env
sudo pip install odoo-env

# install docker
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
rm get-docker.sh

# install docker composer
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#  Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose

# test tools
oe -h -v
sd --version
docker-compose --version

Ok this is all we need in the host, now begin creating a project

You have to select a short and memorable project name and please it must be unique for you. We selected myproject as proyect name, then a minimum manifest working will be:

    ##############################################################################
    #    Copyright (C) 2021 jeo Software  (http://www.jeosoft.com.ar)
    #    All Rights Reserved.
    ##############################################################################

{
    'name': 'myproject',
    'version': '13.0.1.0.0',
    'category': 'Tools',
    'summary': "Project example for v13 CE",
    'author': "jeo Software",
    'license': 'AGPL-3',
    'depends': [],
    'installable': True,
    'application': False,

    'env-ver': '2',

    'git-repos': [
        'https://github.com/jobiols/cl-myproject.git',
        'https://github.com/ingadhoc/odoo-argentina.git',
    ],

    'docker-images': [
        'odoo jobiols/odoo-jeo:13.0',
        'postgres postgres:10.1-alpine',
        'nginx nginx'
    ]
}

You can find this project at https://github.com/jobiols/cl-example.git branch 13.0

Then go to your VPS and clone this:

git clone https://github.com/jobiols/cl-myproject.git

cd inside the repo and issue this command

oe -i -c myproject

Then you can find a directory structure as this

/odoo_ar
└── odoo-13.0
    └── myproject
        ├── config
        ├── data_dir
        ├── log
        ├── postgresql
        └── sources
            ├── cl-myproject
            └── odoo-argentina

You can remove the proyect you clone at first as it will not be used anymore, and can lead to confusion. The useful one is in sources/

Then issue the command:

oe -R -r --nginx

This will download all the necesary images and start them.

The odoo database manager starts blocked in nginex, so you have to comment some lines at the bottom of /odoo_ar/nginx/conf/nginx.conf

# Block database manager and selector
location ~* /web/database/manager {
        return 404;
}
location ~* /web/database/selector {
        return 404;
}

This will unblock the database manager and let you start working with odoo databases.

now some commands:

Restart odoo

oe -s -r

Stop all images

sd rmall

Start all again

oe -R -r --nginx

Update all repositories

oe -i

Pull all images

oe -p

Update odoo database

oe -u

Restore last backup

oe --restore

Restore last production backup

oe --restore --from-prod

Restore last production backup without deactivation (this may be dangerous)

oe --restore --from-prod --no-deactivate

Configuration File

odoo-env stores a configuration file at ~/.config/oe/oe_config.yaml

base_dir: /odoo/ar/
client: emafi
clients:
    - danone: /odoo/ar/odoo-14.0e/danone/sources/cl-danone/danone_default
    - atm: /odoo/ar/odoo-13.0/atm/sources/cl-atm/atm_default
    - villandry: /odoo/ar/odoo-13.0e/villandry/sources/cl-villandry/villandry_default
    - caepso: /odoo/ar/odoo-13.0e/caepso/sources/cl-caepso/caepso_default
    - emafi: /odoo/ar/odoo-13.0e/emafi/sources/cl-emafi/emafi_default
    - lopez: /odoo/ar/odoo-16.0e/lopez/sources/cl-lopez/lopez_default
environment: debug
last_version_check: '2023-09-27'

Note that base_dir starts at /odoo_ar/ by default, in some systems as MAC OS this should be changed.