diff options
| author | Raphael Collet <rco@odoo.com> | 2017-07-10 12:35:02 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2017-07-10 12:38:25 +0200 |
| commit | faacacb45fbda8cb444365dff2137ae3f56ce247 (patch) | |
| tree | b69fc5efecb5ed092586c8be809e16c2dc2d90de /odoo/modules | |
| parent | e2739d6e49db5c6d70f4dd5b0942269e88ab366a (diff) | |
[IMP] registry: check existence of tables with a single SQL query
Diffstat (limited to 'odoo/modules')
| -rw-r--r-- | odoo/modules/registry.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index 71d7b5d9fbe..cade92c23ac 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -15,9 +15,9 @@ import threading import odoo from .. import SUPERUSER_ID -from odoo.tools import (assertion_report, lazy_classproperty, config, - lazy_property, table_exists, topological_sort, - OrderedSet, pycompat) +from odoo.tools import (assertion_report, config, existing_tables, + lazy_classproperty, lazy_property, table_exists, + topological_sort, OrderedSet, pycompat) from odoo.tools.lru import LRU _logger = logging.getLogger(__name__) @@ -310,10 +310,10 @@ class Registry(Mapping): models[0].recompute() # make sure all tables are present - missing = [name - for name, model in pycompat.items(env) - if not model._abstract and not table_exists(cr, model._table)] - if missing: + table2model = {model._table: name for name, model in env.items() if not model._abstract} + missing_tables = set(table2model).difference(existing_tables(cr, table2model)) + if missing_tables: + missing = {table2model[table] for table in missing_tables} _logger.warning("Models have no table: %s.", ", ".join(missing)) # recreate missing tables following model dependencies deps = {name: model._depends for name, model in pycompat.items(env)} @@ -322,9 +322,9 @@ class Registry(Mapping): _logger.info("Recreate table of model %s.", name) env[name].init() # check again, and log errors if tables are still missing - for name, model in pycompat.items(env): - if not model._abstract and not table_exists(cr, model._table): - _logger.error("Model %s has no table.", name) + missing_tables = set(table2model).difference(existing_tables(cr, table2model)) + for table in missing_tables: + _logger.error("Model %s has no table.", table2model[table]) @lazy_property def cache(self): |
