Package: odoo-autodiscover
Enhance Odoo to automatically discover available addons without the need of
the--addons-pathoption.For Odoo 8 and 9, it works by looking at addons in theodoo_addonsnamespace package. For Odoo 10 and 11, it
works by looking forodoo/addonsdirectories in PYTHONPATH.Addons that install this way can be packaged with the help ofsetuptools-odoo.How to installCreate a virtualenv and make sure you have a recent version of pip
(by runningpip install-Upipor usingget-pip.py).Install Odoo in your virtualenv with the standard Odoo installation procedure
(a good way is to runpip install-e.from the Odoo root directory).Make sure Odoo is installed correctly:pip listmust showodoo.for Odoo 8 and 9, runningpython-c"import openerp.api"andopenerp-servermust workfor Odoo 10 and 11, runningpython-c"import odoo.api"andodoomust workInstall this package (pip installodoo-autodiscover).How to useCreate and/or install odoo addons in theodoo/addonsnamespace (for Odoo 10 and 11)
or theodoo_addonsnamespace (for Odoo 8 and 9),
possibly with the help of thesetuptools-odoopackage.Run odoo as usual and notice the addons path is extended automatically.Complete exampleThe following commands install Odoo 8.0 nightly, then
installbase_import_asyncpulling all required dependencies
automatically (ieconnector).It uses pre-built wheel packages for OCA addons from pypi.# create and activate a virtualenvvirtualenvvenv../venv/bin/activate# install Odoo 8.0 nightlypipinstall-rhttps://raw.githubusercontent.com/odoo/odoo/8.0/requirements.txtpipinstallhttps://nightly.odoo.com/8.0/nightly/src/odoo_8.0.latest.zip# install odoo-autodiscoverpipinstallodoo-autodiscover# install base_import_async from pypipipinstallodoo8-addon-base_import_async--pre# start odooopenerp-serverAt this point, you should see in the Odoo log that the site-packages directory appears in the addons path.You can easily install additional addons. For example, should you like to have an Odoo 8 shell,
using the OCA shell module, simply pip install the module:pipinstallodoo8-addon-shellopenerp-servershellTo view addon packages that are installed in your virtualenv,
simply usepip list | grepodoo<8|9|10>-addon-(note official addons
are part of theodoopackage).Technical notesWith Odoo 8 and 9 it’s not possible to makeopenerp.addonsa namespace package
(becauseopenerp/__init__.pycontains code), we use a pseudo-package namedodoo_addonsfor the sole purpose of discovering addons installed with
setuptools in that namespace.odoo_addonsis not intended to be imported
as the Odoo import hook will make sure all addons can be imported fromopenerp.addonsas usual.With Odoo 10, we attempted to use pkg_resource style namespace packages.
It worked fine until setuptools 31, at which point we had to cope withhttps://github.com/acsone/setuptools-odoo/issues/10. Hence the workaround
inodoo-autodiscover2.0.For Odoo 11 under Python 3, we hope we can makeodoo-autodiscoverobsolete
again, this is the purpose ofhttps://github.com/odoo/odoo/pull/19517.Seehttps://packaging.python.org/guides/packaging-namespace-packages/for more
information about namespace packages.Useful linkspypi page:https://pypi.python.org/pypi/odoo-autodiscovercode repository:https://github.com/acsone/odoo-autodiscoverreport issues at:https://github.com/acsone/odoo-autodiscover/issuessee also setuptools-odoo:https://pypi.python.org/pypi/setuptools-odooCreditsAuthor: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.Changes2.0.0 (2017-09-19)better deprecation warnings for autodiscover scriptsimprovements to setup.py and readmeadd test for Odoo 11 and python 3 where odoo-autodiscover is not necessary2.0.0b1 (2017-09-17)major rewrite: instead of adapted startup scripts that monkey patch Odoo,
use a post import hook that automatically does the job as soon as odoo or openerp
is imported.for Odoo 10 and 11, do not rely on namespace packages, but instead look for odoo/addons
directories in PYTHONPATHautomated testsOdoo 10 support, to work aroundhttps://github.com/acsone/setuptools-odoo/issues/10preliminary Odoo 11 support1.0.3 (2016-09-30)odoo-autodiscover is built-in Odoo 10!1.0.2 (2016-02-06)[IMP] add openerp-gevent-autodiscover, and monkey patch the prefork server
to launch that script instead of openerp-gevent.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 package1.0.0 (2015-12-28)initial stable release