summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2020-02-10 15:01:17 +0000
committerRaphael Collet <rco@odoo.com>2020-02-12 10:16:11 +0000
commit7483fdfce0ec6290237448b82cf29003332db6b0 (patch)
tree61b2b26de5d0881e57507114e789f17a3000a4b6 /odoo/modules/loading.py
parente95ccf0908c263f6cf23c91c477a8e252e936ff1 (diff)
[FIX] core: flush env after pre upgrade scripts
In some case, a pre-migration script calls `xml_import.parse` to force reload a no-update data in pre-script. It is possible that fields are marked to recompute in the process. The problem is that the reference to the field added in `env.all.tocompute` won't be the same as the reference of the same field after calling `registry.setup_models()`, leading to an infinite loop while recomputing this field, since `fields.__get__` wont find `self` in `env.all.tocompute`. This problem was discovered when trying to migrate a database with all modules installed (no demo data) from 12.0 to 13.0 (for commit references: http://runbot.odoo.com/runbot/build/1176576 with database comming from http://runbot.odoo.com/runbot/build/1171714). This commit adds a check before executing `registry.setup_models()` in order to log when some fields to compute remain before breaking fields references, and adds a `flush()` after pre-scripts to fix the current issue. X-original-commit: 41b9d810066774736c4077bba1dc9c9fba004f48
Diffstat (limited to 'odoo/modules/loading.py')
-rw-r--r--odoo/modules/loading.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index 7e20af9033e..5c388026a20 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -175,6 +175,9 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
if package.name != 'base':
registry.setup_models(cr)
migrations.migrate_module(package, 'pre')
+ if package.name != 'base':
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ env['base'].flush()
load_openerp_module(package.name)