Skip to content

Commit

Permalink
[FIX] FakeModelLoader: avoid loading module again on restore_registry…
Browse files Browse the repository at this point in the history
…() for Odoo 15.0+
  • Loading branch information
nilshamerlinck committed Oct 17, 2023
1 parent 3c93527 commit 0b20ccd
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions odoo_test_helper/fake_model_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,16 @@ def restore_registry(self):

self._clean_module_to_model()

# reload is need to reset correctly the field on the record
with mock.patch.object(self.env.cr, "commit"):
# Only before V15
if hasattr(self.env.registry, "model_cache"):
# reload is needed to reset correctly the field on the record
# but only up to Odoo 14
if version_info[0] < 15:

with mock.patch.object(self.env.cr, "commit"):
self.env.registry.model_cache.clear()
model_names = self.env.registry.load(
self.env.cr, FakePackage(self._module_name)
)
self.env.registry.setup_models(self.env.cr)
self.env.registry.init_models(
self.env.cr, model_names, {"module": self._module_name}
)
model_names = self.env.registry.load(
self.env.cr, FakePackage(self._module_name)
)
self.env.registry.setup_models(self.env.cr)
self.env.registry.init_models(
self.env.cr, model_names, {"module": self._module_name}
)

0 comments on commit 0b20ccd

Please sign in to comment.