[FIX] core: KeyError odoo.fields in compute_value

`field_computed` is decorated with `lazy_property` and will be reset by
`setup_models` If a request comes, read `field_compute` when `setup_models`
just clears some fields. The `field_compute` will be cached with fewer fields
and cause KeyError for the registry in the future.

This commit re-clear lazy_property for registry after fields are modified

X-original-commit: 04e35d7bf3ca98dc722795c75033747697d70d30
Part-of: odoo/odoo#146544
This commit is contained in:
Chong Wang (cwg)
2023-12-15 21:02:10 +00:00
parent 6341805d5c
commit a7f2056b15
+3
View File
@@ -333,6 +333,9 @@ class Registry(Mapping):
self.field_depends[field] = tuple(depends)
self.field_depends_context[field] = tuple(depends_context)
# clean the lazy_property again in case they are cached by another ongoing registry readonly request
lazy_property.reset_all(self)
# Reinstall registry hooks. Because of the condition, this only happens
# on a fully loaded registry, and not on a registry being loaded.
if self.ready: