summaryrefslogtreecommitdiff
path: root/odoo/modules
diff options
context:
space:
mode:
Diffstat (limited to 'odoo/modules')
-rw-r--r--odoo/modules/loading.py5
-rw-r--r--odoo/modules/registry.py33
2 files changed, 10 insertions, 28 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index bc423861c90..1551bdc3800 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -268,6 +268,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
for kind in ('init', 'demo', 'update'):
if hasattr(package, kind):
delattr(package, kind)
+ module.flush()
if package.name is not None:
registry._init_modules.add(package.name)
@@ -391,7 +392,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
cr.execute("update ir_module_module set state=%s where name=%s", ('installed', 'base'))
Module.invalidate_cache(['state'])
-
+ Module.flush()
# STEP 3: Load marked modules (skipping base which was done in STEP 1)
# IMPORTANT: this is done in two parts, first loading all installed or
@@ -451,6 +452,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
# Cleanup orphan records
env['ir.model.data']._process_end(processed_modules)
+ env['base'].flush()
for kind in ('init', 'demo', 'update'):
tools.config[kind] = {}
@@ -513,6 +515,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
env = api.Environment(cr, SUPERUSER_ID, {})
for model in env.values():
model._register_hook()
+ env['base'].flush()
# STEP 9: save installed/updated modules for post-install tests
registry.updated_modules += processed_modules
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 99a920f233d..c3930d3f425 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -183,25 +183,6 @@ class Registry(Mapping):
""" Add or replace a model in the registry."""
self.models[model_name] = model
- @lazy_property
- def field_sequence(self):
- """ Return a function mapping a field to an integer. The value of a
- field is guaranteed to be strictly greater than the value of the
- field's dependencies.
- """
- # map fields on their dependents
- dependents = {
- field: set(dep for dep, _ in model._field_triggers[field] if dep != field)
- for model in self.values()
- for field in model._fields.values()
- }
- # sort them topologically, and associate a sequence number to each field
- mapping = {
- field: num
- for num, field in enumerate(reversed(topological_sort(dependents)))
- }
- return mapping.get
-
def descendants(self, model_names, *kinds):
""" Return the models corresponding to ``model_names`` and all those
that inherit/inherits from them.
@@ -300,8 +281,7 @@ class Registry(Mapping):
func = self._post_init_queue.popleft()
func()
- if models:
- models[0].recompute()
+ env['base'].flush()
# make sure all tables are present
self.check_tables_exist(cr)
@@ -317,12 +297,11 @@ class Registry(Mapping):
if missing_tables:
missing = {table2model[table] for table in missing_tables}
_logger.info("Models have no table: %s.", ", ".join(missing))
- # recreate missing tables following model dependencies
- deps = {name: model._depends for name, model in env.items()}
- for name in topological_sort(deps):
- if name in missing:
- _logger.info("Recreate table of model %s.", name)
- env[name].init()
+ # recreate missing tables
+ for name in missing:
+ _logger.info("Recreate table of model %s.", name)
+ env[name].init()
+ env['base'].flush()
# check again, and log errors if tables are still missing
missing_tables = set(table2model).difference(existing_tables(cr, table2model))
for table in missing_tables: