上QQ阅读APP看书,第一时间看更新
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 in a subdirectory called env/:
$ virtualenv -p python3 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 and of the various third-party addon projects (refer to step 4 in this recipe)
- local/: This is used to save your instance-specific addons
- 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):
$ git clone 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, asking to exclude filestore/, env/, logs/ and src/:
# 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"