Skip to content

AssertionError on hr.leave creation due to incomplete ORM cache in create_full #3638

Description

@shochstoeger

module: auditlog
version: 19.0

Steps to reproduce

  • Install the auditlog module from OCA server-tools
  • Configure an audit log rule for the hr.leave model
  • Create a new time-off request (hr.leave) via the UI

Current behavior
An AssertionError is raised during record creation:

...
  File "/home/odoo/src/user/addons/server-tools/auditlog/models/auditlog_rule.py", line 385, in create_full
    new_record[fname], new_record
...
  File "/home/odoo/src/odoo/odoo/orm/models.py", line 6425, in _flush
    raise AssertionError(
AssertionError: Could not find all values of mail.activity(<id>,) to flush them

The error originates in auditlog_rule.py line 385 in create_full, where it tries to access new_record[fname] for relational fields (e.g. activity_ids) before the ORM cache is fully populated for related records created as side effects during hr.leave creation. The record is never saved and the user sees a generic server error.

Expected behavior

The audit log entry should be created successfully without interfering with the hr.leave creation. Accessing field values on the newly created record in create_full should either invalidate the cache first or handle the case where related records created as side effects are not yet fully cached, so the full ORM flush can complete without raising an AssertionError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions