How to do it…
To create the proposed instance layout, you need to perform the following steps:
- Create one directory per instance:
$ mkdir ~/odoo-dev/projectname $ cd ~/odoo-dev/projectname
- Create a Python
virtualenv
object in a subdirectory calledenv/
:$ python3 -m venv env
- Create some subdirectories, as follows:
$ mkdir src local bin filestore logs
The functions of the subdirectories are as follows:
src/
: This contains the clone of Odoo itself, as well as the various third-party add-on projects (we have added Odoo source code to the next step in this recipe).local/
: This is used to save your instance-specific add-ons.bin/
: This includes various helper executable shell scripts.filestore/
: This is used as a file store.logs/
(optional): This is used to store the server log files.
- Clone Odoo and install the requirements (refer to Chapter 1, Installing the Odoo Development Environment, for details on this):
$ git clone -b 14.0 --single-branch --depth 1 https://github.com/odoo/odoo.git src/odoo $ env/bin/pip3 install -r src/odoo/requirements.txt
- Save the following shell script as
bin/odoo
:#!/bin/sh ROOT=$(dirname $0)/.. PYTHON=$ROOT/env/bin/python3 ODOO=$ROOT/src/odoo/odoo-bin $PYTHON $ODOO -c $ROOT/projectname.cfg "$@" exit $?
- Make the script executable:
$ chmod +x bin/odoo
- Create an empty dummy local module:
$ mkdir -p local/dummy $ touch local/dummy/  init  .py $ echo '{"name": "dummy", "installable": False}' >\ local/dummy/  manifest  .py
- Generate a configuration file for your instance:
$ bin/odoo --stop-after-init --save \ --addons-path src/odoo/odoo/addons,src/odoo/addons,local \ --data-dir filestore
- Add a
.gitignore
file, which is used to tell GitHub to exclude given directories so that Git will ignore these directories when you commit the code, for example,filestore/
,env/
,logs/
, andsrc/
:# dotfiles, with exceptions: .* !.gitignore # python compiled files *.py[co] # emacs backup files *~ # not tracked subdirectories /env/ /src/ /filestore/ /logs/
- Create a Git repository for this instance and add the files you've added to Git:
$ git init $ git add . $ git commit -m "initial version of projectname"