Skip to content

[19.0] auditlog: Error when deleting Website Menu #3680

Description

@DucTruongKomit

Module

[19.0]auditlog

Describe the bug

Error appears blocking the users to delete the Menu items.

To Reproduce

  1. Install module website and auditlog, then create a record auditlog rule for website.menu:
Image
  1. Create a new Menu Item, and then click delete and click save:
Image
  1. The error will appear:
Image
Full traceback
AssertionError: Could not find all values of website.menu(26,) to flush them
    Context: {'lang': 'en_US', 'tz': 'Asia/Hong_Kong', 'uid': 2, 'allowed_company_ids': [1], 'is_redirect_to_home': False, 'auditlog_disabled': True, 'prefetch_fields': False}
    Cache: {'website.menu.child_id': {}, 'website.menu.controller_page_id': {}, 'website.menu.create_date': {}, 'website.menu.create_uid': {}, 'website.menu.group_ids': {}, 'website.menu.mega_menu_classes': {}, 'website.menu.mega_menu_content': {}, 'website.menu.name': {}, 'website.menu.new_window': {}, 'website.menu.page_id': {}, 'website.menu.parent_id': {}, 'website.menu.parent_path': {}, 'website.menu.sequence': {}, 'website.menu.theme_template_id': {}, 'website.menu.url': {}, 'website.menu.website_id': {}, 'website.menu.write_date': {}, 'website.menu.write_uid': {}}

  File ".../odoo/orm/models.py", line 6427, in _flush
    raise AssertionError(...)
  File ".../odoo/orm/environments.py", line 525, in flush_query
    self[model_name].flush_model(field_names)
  File ".../odoo-addons/website/models/website_menu.py", line 344, in save
    menu_id.write(menu)
  File ".../oca-server-tools/auditlog/models/auditlog_rule.py", line 486, in write_full
    result = write_full.origin(self, vals, **kwargs)
  File ".../odoo-addons/website/models/website_menu.py", line 156, in write
    res = super().write(vals)
  File ".../odoo/orm/fields.py", line 1924, in determine_inverse
    determine(self.inverse, records)
  File ".../odoo-addons/website/models/website_menu.py", line 38, in _set_field_is_mega_menu
    menu.mega_menu_content = False
  File ".../odoo/orm/fields.py", line 1843, in __set__
    records.write({self.name: write_value})
  File ".../oca-server-tools/auditlog/models/auditlog_rule.py", line 484, in write_full
    old_values = {d["id"]: d for d in records_write.read(fields_list)}

Expected behavior
Click Save and no error; the deleted menu item is removed as normal.

Additional context

  • Odoo 19.0.
  • Workaround: disabling the auditlog.rule for website.menu avoids the crash (loses the audit
    trail for that model in the meantime).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions