Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] component_event: _event method using incorrect fallback object #480

Open
oerp-odoo opened this issue Jan 9, 2024 · 0 comments
Open
Labels

Comments

@oerp-odoo
Copy link

oerp-odoo commented Jan 9, 2024

Module

component_event

Describe the bug

When _event method is called that is defined in base model, and if there is no components_registry provided. The one that is used in fallback, produces this error:

2024-01-09 13:59:09,569 1 ERROR odoodb odoo.modules.registry: Failed to load registry 
Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/odoo/odoo/modules/loading.py", line 595, in load_modules
    env['res.groups']._update_user_groups_view()
  File "/opt/odoo/odoo/odoo/addons/base/models/res_users.py", line 1509, in _update_user_groups_view
    view.with_context(new_context).write({'arch': xml_content})
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 573, in write
    res = super(View, self).write(self._compute_defaults(vals))
  File "/opt/odoo/projects/connector/component_event/models/base.py", line 109, in write
    result = super(Base, self).write(vals)
  File "/opt/odoo/odoo/odoo/models.py", line 3801, in write
    fields[0].determine_inverse(real_recs)
  File "/opt/odoo/odoo/odoo/fields.py", line 1400, in determine_inverse
    determine(self.inverse, records)
  File "/opt/odoo/odoo/odoo/fields.py", line 97, in determine
    return needle(*args)
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 340, in _inverse_arch
    view.write(data)
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_ui_view.py", line 573, in write
    res = super(View, self).write(self._compute_defaults(vals))
  File "/opt/odoo/projects/connector/component_event/models/base.py", line 112, in write
    self._event("on_record_write").notify(record, fields=fields)
  File "/opt/odoo/projects/connector/component_event/models/base.py", line 70, in _event
    if not comp_registry or not comp_registry.ready:
AttributeError: 'collections.defaultdict' object has no attribute 'ready'

To Reproduce

Affected versions: 16.0

Steps to reproduce the behavior:

  1. This was encountered, when installing/upgrading base_rest module with --test-enable.

Expected behavior
Should not throw any error. Also another problematic thing with this is that tests won't simply fail, but odoo will crash entirely, stopping any other tests from running as well.

Additional context
The problem lies here:

comp_registry = components_registry or _component_databases.get(dbname)

It tries to use this class instance as a fallback:
class ComponentDatabases(dict):
`

Though that is just a simple dict subclass, which has no such attribute as ready.
But next to that class, there is ComponentRegistry which does have ready attribute. So I guess thats the one that should be used? Though not sure, how it is intended to be used there. Should it just simply be initiated on demand or we need to reuse some existing instance of that class?

@oerp-odoo oerp-odoo added the bug label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant