[FIX] core: using absolute paths

Start odoo-bin using a tier module (like `python3 -m pdb odoo-bin`), the
odoo/addons __path__ contains the relative link to the modules instead
of the absolute link like when directly started (`python3 odoo-bin`).

This cause trouble importing modules because it reuses the relative path
from within other directories.

closes odoo/odoo#39182

X-original-commit: 941e051fc6b33e7a90400c77d63d589049b027a6
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Julien Castiaux
2019-10-22 13:17:03 +00:00
committed by fw-bot
parent 54df22c112
commit 7ef68e4b0e
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -8,7 +8,12 @@
# odoo must be a namespace package for odoo.addons to become one too
# https://packaging.python.org/guides/packaging-namespace-packages/
#----------------------------------------------------------
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
import pkgutil
import os.path
__path__ = [
os.path.abspath(path)
for path in pkgutil.extend_path(__path__, __name__)
]
import sys
assert sys.version_info > (3, 6), "Outdated python version detected, Odoo requires Python >= 3.6 to run."
+6 -1
View File
@@ -17,4 +17,9 @@ Importing them from here is deprecated.
# make odoo.addons a namespace package, while keeping this __init__.py
# present, for python 2 compatibility
# https://packaging.python.org/guides/packaging-namespace-packages/
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
import pkgutil
import os.path
__path__ = [
os.path.abspath(path)
for path in pkgutil.extend_path(__path__, __name__)
]