[FIX] ensure default addon paths are valid (existing)

User-provided addons paths are checked for existence (and rejected), but
default addons paths are not checked, and blow up when trying to listdir
them (e.g. when http.py tries to load modules).

This is an issue when using Odoo from the distributed tarballs, because
the packaging currently moves all modules to openerp/addons and removes
the root ("main") addons directory.
This commit is contained in:
Xavier Morel 2014-12-05 15:27:58 +01:00 committed by Christophe Simonis
parent 4630226514
commit a2115ef544
1 changed files with 6 additions and 1 deletions

View File

@ -445,9 +445,14 @@ class configmanager(object):
self.options['root_path'] = os.path.abspath(os.path.expanduser(os.path.expandvars(os.path.dirname(openerp.__file__))))
if not self.options['addons_path'] or self.options['addons_path']=='None':
default_addons = []
base_addons = os.path.join(self.options['root_path'], 'addons')
if os.path.exists(base_addons):
default_addons.append(base_addons)
main_addons = os.path.abspath(os.path.join(self.options['root_path'], '../addons'))
self.options['addons_path'] = '%s,%s' % (base_addons, main_addons)
if os.path.exists(main_addons):
default_addons.append(main_addons)
self.options['addons_path'] = ','.join(default_addons)
else:
self.options['addons_path'] = ",".join(
os.path.abspath(os.path.expanduser(os.path.expandvars(x)))