summaryrefslogtreecommitdiff
path: root/addons/base_import_module/models/ir_module.py
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2019-09-09 16:10:13 +0000
committerJulien Castiaux <juc@odoo.com>2019-09-16 09:31:38 +0000
commit7c47eb185443af08a55b0045c6a78f74151dc083 (patch)
treeff74975923ba2da758df1df16018e6b875d5337c /addons/base_import_module/models/ir_module.py
parent760ab74f831dcbd2c2e48c5dbfbbf46df383cba7 (diff)
[IMP] module.py: deprecate openerp
[PEP-594] is deprecating the `imp` module, that module is used in `module.py` in order to dynamically import addons using any of the `odoo.addons` or `openerp.addons` import anchor. We are deprecating `openerp` module/addons imports in v13 in order to remove the support in v14 and greatly simplify how modules/addons are loaded. If you are still using the old `import openerp` or `import openerp.addons`, `import odoo` and `import odoo.addons` are drop-in replacements. The `odoo.modules.module.ad_paths` addon paths list has been deprecated too. The list is now accessible on `odoo.addons.__path__` where they are now directly loaded [2]. See also: [PEP-594]: https://python.org/dev/peps/pep-0594/ [2]: https://packaging.python.org/guides/packaging-namespace-packages/ closes odoo/odoo#36597 Task: 2003936 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'addons/base_import_module/models/ir_module.py')
-rw-r--r--addons/base_import_module/models/ir_module.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/base_import_module/models/ir_module.py b/addons/base_import_module/models/ir_module.py
index ce1499941a9..eda9562fd65 100644
--- a/addons/base_import_module/models/ir_module.py
+++ b/addons/base_import_module/models/ir_module.py
@@ -8,6 +8,7 @@ import sys
import zipfile
from os.path import join as opj
+import odoo
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.modules import load_information_from_description_file
@@ -125,7 +126,7 @@ class IrModule(models.Model):
with tempdir() as module_dir:
import odoo.modules.module as module
try:
- module.ad_paths.append(module_dir)
+ odoo.addons.__path__.append(module_dir)
z.extractall(module_dir)
dirs = [d for d in os.listdir(module_dir) if os.path.isdir(opj(module_dir, d))]
for mod_name in dirs:
@@ -139,7 +140,7 @@ class IrModule(models.Model):
_logger.exception('Error while importing module')
errors[mod_name] = exception_to_unicode(e)
finally:
- module.ad_paths.remove(module_dir)
+ odoo.addons.__path__.remove(module_dir)
r = ["Successfully imported module '%s'" % mod for mod in success]
for mod, error in errors.items():
r.append("Error while importing module '%s'.\n\n %s \n Make sure those modules are installed and try again." % (mod, error))