[FIX] core: avoid 'Registry' object has no attribute '_m2m' error

If `setup_models` is called concurrently,
the first one just delete the `registry._m2m`.
then the latter one tries to access `registry._m2m`.
An error 'Registry' object has no attribute '_m2m' will be raised

This commit add a lock to the `setup_model` to fix the problem

X-original-commit: 9ae78193f5c9ae4dcfa28c4ea4be1a7f98e42136
Part-of: odoo/odoo#146544
This commit is contained in:
Chong Wang (cwg)
2023-12-15 21:02:10 +00:00
parent 6d14689280
commit 6341805d5c
+1
View File
@@ -273,6 +273,7 @@ class Registry(Mapping):
return self.descendants(model_names, '_inherit', '_inherits')
@locked
def setup_models(self, cr):
""" Complete the setup of models.
This must be called after loading modules and before using the ORM.