Skip to content

Commit

Permalink
[FIX] component_event: comp_registry.ready
Browse files Browse the repository at this point in the history
For some reason dict is used when checking for `ready` attribute which
won't exist. So for now we simply handle that exception and fallback
as if no registry was found.
  • Loading branch information
oerp-odoo committed Jun 10, 2024
1 parent 3dd7b3a commit 55c4f46
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions component_event/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,19 @@ def button_do_something(self):
"components_registry", components_registry
)
comp_registry = components_registry or _component_databases.get(dbname)
if not comp_registry or not comp_registry.ready:
# No event should be triggered before the registry has been loaded
# This is a very special case, when the odoo registry is being
# built, it calls odoo.modules.loading.load_modules().
# This function might trigger events (by writing on records, ...).
# But at this point, the component registry is not guaranteed
# to be ready, and anyway we should probably not trigger events
# during the initialization. Hence we return an empty list of
# events, the 'notify' calls will do nothing.
try:
if not comp_registry or not comp_registry.ready:
# No event should be triggered before the registry has been loaded
# This is a very special case, when the odoo registry is being
# built, it calls odoo.modules.loading.load_modules().
# This function might trigger events (by writing on records, ...).
# But at this point, the component registry is not guaranteed
# to be ready, and anyway we should probably not trigger events
# during the initialization. Hence we return an empty list of
# events, the 'notify' calls will do nothing.
return CollectedEvents([])
# comp_registry can be dict, so it won't have `ready` attribute..
except AttributeError:
return CollectedEvents([])
if not comp_registry.get("base.event.collecter"):
return CollectedEvents([])
Expand Down

0 comments on commit 55c4f46

Please sign in to comment.