From d47083e6d219bdd2ca0e36a41aef5274f67a70f1 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Mon, 9 Sep 2019 16:10:13 +0000 Subject: [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) --- addons/base_import_module/models/ir_module.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/base_import_module') 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)) -- cgit v1.2.3