diff options
| author | xmo-odoo <xmo@odoo.com> | 2017-05-10 09:39:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 09:39:55 +0200 |
| commit | fffaf735f58f1ac57781c095eb552de6d1fcdc47 (patch) | |
| tree | 88ab0ab65430d871862a836524e0ecc890d1674d /odoo/modules/loading.py | |
| parent | 10eee18a047d35305dc46282e610e88936d81ffc (diff) | |
[FIX] P3: list -> iterable builtins (#16811)
In Python 3:
* various builtins and dict methods were changed to return
view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
removed altogether
This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).
Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.
issue #8530
Diffstat (limited to 'odoo/modules/loading.py')
| -rw-r--r-- | odoo/modules/loading.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py index f8c65d40177..bd58376a7b9 100644 --- a/odoo/modules/loading.py +++ b/odoo/modules/loading.py @@ -20,6 +20,7 @@ import odoo.tools as tools from odoo import api, SUPERUSER_ID from odoo.modules.module import adapt_version, initialize_sys_path, load_openerp_module +from odoo.tools import pycompat _logger = logging.getLogger(__name__) _test_logger = logging.getLogger('odoo.tests') @@ -295,15 +296,15 @@ def load_modules(db, force_demo=False, status=None, update_module=False): _logger.info('updating modules list') Module.update_list() - _check_module_names(cr, itertools.chain(tools.config['init'].keys(), tools.config['update'].keys())) + _check_module_names(cr, itertools.chain(tools.config['init'], tools.config['update'])) - module_names = [k for k, v in tools.config['init'].items() if v] + module_names = [k for k, v in pycompat.items(tools.config['init']) if v] if module_names: modules = Module.search([('state', '=', 'uninstalled'), ('name', 'in', module_names)]) if modules: modules.button_install() - module_names = [k for k, v in tools.config['update'].items() if v] + module_names = [k for k, v in pycompat.items(tools.config['update']) if v] if module_names: modules = Module.search([('state', '=', 'installed'), ('name', 'in', module_names)]) if modules: @@ -391,7 +392,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): getattr(py_module, uninstall_hook)(cr, registry) Module = env['ir.module.module'] - Module.browse(modules_to_remove.values()).module_uninstall() + Module.browse(pycompat.values(modules_to_remove)).module_uninstall() # Recursive reload, should only happen once, because there should be no # modules to remove next time cr.commit() @@ -414,7 +415,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): _logger.info('Modules loaded.') # STEP 8: call _register_hook on every model - for model in env.values(): + for model in pycompat.values(env): model._register_hook() # STEP 9: save installed/updated modules for post-install tests |
