[FIX] core: invalidate registry at the start of setup_models

This is necessary in order to create models on-the-fly within tests and
to test improper Model / Field creation: registry.reset_changes will
only perform the reset of the registry if it is invalidated, however if
the setup of models crashes before it is invalidated (as is the case of
a test), the reset_changes will not be triggered and thus the registry
will be left dirty for subsequent tests.
This commit is contained in:
Adrian Torres
2020-03-30 13:42:04 +00:00
committed by Raphael Collet
parent 73dc42d6d5
commit 96223568c4
+1 -2
View File
@@ -235,6 +235,7 @@ class Registry(Mapping):
This must be called after loading modules and before using the ORM.
"""
lazy_property.reset_all(self)
self.registry_invalidated = True
env = odoo.api.Environment(cr, SUPERUSER_ID, {})
if env.all.tocompute:
@@ -303,8 +304,6 @@ class Registry(Mapping):
for model in models:
model._setup_complete()
self.registry_invalidated = True
def post_init(self, func, *args, **kwargs):
""" Register a function to call at the end of :meth:`~.init_models`. """
self._post_init_queue.append(partial(func, *args, **kwargs))