An Odoo launcher that discovers addons automatically
Project description
Odoo server startup scripts that discover Odoo addons automatically without the need of the --addons-path option. They work by looking at addons in the odoo_addons namespace package.
This is the basic building block to package and distribute Odoo addons using standard python infrastructure (ie setuptools, pip, wheel, and pypi).
The following thin wrappers around official Odoo startup scripts are provided:
odoo-autodiscover.py is the equivalent of odoo.py
openerp-server-autodiscover is the equivalent of openerp-server
odoo-server-autodiscover is an alias for openerp-server-autodiscover
These scripts have exactly the same behaviour and options as their official Odoo counterparts, except they look for additional addons by examining all distributions providing the odoo_addons namespace package.
How to install
create a virtualenv and make sure you have a recent version of pip (by running pip install -U pip or using get-pip.py)
install Odoo with the standard Odoo installation procedure
make sure Odoo is installed (the following commands must work: python -c "import openerp", odoo.py and openerp-server, and pip list must show the odoo package)
install this package (pip install odoo-autodiscover)
How to use
create or install odoo addons in the odoo_addons namespace package possibly with the help of the setuptools-odoo package.
run odoo with openerp-server-autodiscover or odoo-autodiscover.py and notice the addons path is constructued automatically
Complete example
The following commands install Odoo 8.0 nightly, then install base_import_async pulling all required dependencies automatically (ie connector).
It uses pre-built wheel packages at https://wheelhouse.acsone.eu, so the procedure is extremely fast and you don’t need any compiler nor build dependencies.
# create and activate a virtualenv virtualenv venv . ./venv/bin/activate # install Odoo 8.0 nightly pip install -r https://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txt \ --find-links=https://wheelhouse.acsone.eu/odoo-requirements --no-index pip install https://nightly.odoo.com/8.0/nightly/src/odoo_8.0.latest.zip # install odoo-autodiscover pip install odoo-autodiscover # install base_import_async from wheelhouse.acsone.eu pip install odoo-addon-base_import_async \ --find-links=https://wheelhouse.acsone.eu/oca-8.0 --no-index # start odoo openerp-server-autodiscover
Should you like to have an Odoo shell, simply pip install the module:
pip install odoo-addon-shell \ --find-links=https://wheelhouse.acsone.eu/oca-8.0 --no-index odoo-autodiscover.py shell
To view addon packages that are installed in your virtualenv, simply use pip list | grep odoo-addon- (note official addons are part of the odoo package).
Technical note
Since it’s not possible to make openerp.addons a namespace package (because openerp/__init__.py contains code), we use a pseudo-package named odoo_addons for the sole purpose of discovering addons installed with setuptools in that namespace. odoo_addons is not intended to be imported as the Odoo import hook will make sure all addons can be imported from openerp.addons as usual.
See https://pythonhosted.org/setuptools/pkg_resources.html for more information about namespace packages.
See https://github.com/odoo/odoo/pull/8758 to follow progress with making openerp.addons a namespace package, which will hopefully make this package obsolete in the future.
Useful links
pypi page: https://pypi-hypernode.com/pypi/odoo-autodiscover
code repository: https://github.com/acsone/odoo-autodiscover
report issues at: https://github.com/acsone/odoo-autodiscover/issues
see also setuptools-odoo: https://pypi-hypernode.com/pypi/setuptools-odoo
Credits
Author:
Stéphane Bidoul (ACSONE)
Many thanks to Daniel Reis who cleared the path, and Laurent Mignon who convinced me it was possible to do it using standard Python setup tools and had the idea of the odoo_addons namespace package.
Changes
1.0.1 (2015-12-30)
[FIX] odoo-autodiscover.py: more reliable way to discover and import the official odoo.py script, so it will now work when Odoo is installed from the deb package
1.0.0 (2015-12-28)
initial stable release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file odoo-autodiscover-1.0.1.tar.gz
.
File metadata
- Download URL: odoo-autodiscover-1.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d6acaef172bdb7fdbfd95bf0b3b7b403b13ae461de69f00df8748558f0e9144 |
|
MD5 | 603e6b088339e03a727ffe4cbb2a238a |
|
BLAKE2b-256 | 57fed8ff637a2c4553dee1778250a179f27df27fa541c63c7ef60b39b8a63073 |
File details
Details for the file odoo_autodiscover-1.0.1-py27-none-any.whl
.
File metadata
- Download URL: odoo_autodiscover-1.0.1-py27-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2.7
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0a070ad7c81ba41454526191821ce4dffa1c4699af4b33bbd588316a5560692 |
|
MD5 | e7a6ff3db73021a602b59435f09185f2 |
|
BLAKE2b-256 | 18a0109b2f56d29b2c547cf73b53bce4811f50b1d431a921b863b2e2f75d904f |