How to do it…

To create the proposed instance layout, you need to perform the following steps:

  1. Create one directory per instance:
$ mkdir ~/odoo-dev/projectname
$ cd ~/odoo-dev/projectname
  1. Create a Python virtualenv in a subdirectory called env/:
$ virtualenv -p python3 env
  1. 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 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
  1. Clone Odoo and install the requirements (refer to Chapter 1, Installing the Odoo Development Environment, for details on this):
$ git clone https://github.com/odoo/odoo.git src/odoo
$ env/bin/pip3 install -r src/odoo/requirements.txt
  1. 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 $?
  1. Make the script executable:
$ chmod +x bin/odoo
  1. Create an empty dummy local module:
$ mkdir -p local/dummy
$ touch local/dummy/__init__.py
$ echo '{"name": "dummy", "installable": False}' > local/dummy/__manifest__.py
  1. 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
  1. 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/, and src/:
# dotfiles, with exceptions:
.*
!.gitignore
# python compiled files
*.py[co]
# emacs backup files
*~
# not tracked subdirectories
/env/
/src/
/filestore/
/logs/

  1. 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"
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset