Skip to content

[18.0][FIX] auditlog: don't patch methods while the registry is loading - #3853

Open
parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-auditlog-patch-after-registry-loaded
Open

parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-auditlog-patch-after-registry-loaded

Conversation

@parabol123654

@parabol123654 parabol123654 commented Nov 8, 2026 •

Copy link
Copy Markdown

Fixes #3852 on 18.0 (thanks @Paddy691 for the analysis; the issue is reported on 19.0, and 18.0 has the same code).

When a module ships a subscribed auditlog.rule as data, AuditlogRule.create()/write() call _register_hook() while the registry is still loading. _patch_method() then keeps as origin the write (or create/read/...) of a model class that only has the modules loaded so far. The overrides of the modules loaded afterwards are skipped for the rest of the process. The final _register_hook() pass of load_modules does not patch again either, because the auditlog_ruled_* flag is already set.

The fix: _register_hook() of auditlog.rule does nothing while self.pool.loaded is false. Core sets registry.loaded = True before the final pass that calls _register_hook() on every model, so the rules are applied there, on the complete classes. Rules created or changed afterwards (UI, RPC) are still applied right away.

Test: test_no_patch_while_registry_loading creates and subscribes a rule with registry.loaded = False, checks that write is not patched, then runs the hook on the loaded registry and checks that it is.

  • Without the fix it fails: True is not false.
  • With the fix, all 41 tests of auditlog pass.

Assisted-by: Claude Opus 5.5

@parabol123654
parabol123654 force-pushed the 18.0-fix-auditlog-patch-after-registry-loaded branch from 7915c68 to 88e15f2 Compare November 14, 2026 18:31
A rule created or written as module data called _register_hook() during
the registry loading, so _patch_method() kept as origin the method of a
partially set up model class. The overrides of the modules loaded later
were skipped for the rest of the process, and the final _register_hook()
pass did not patch again because the class flag was already set.

Rules are now only applied once the registry is loaded; the final
_register_hook() pass of the loading applies them on the complete
classes.

Fixes OCA#3852 on 18.0.

Assisted-by: Claude Opus 5.5
@parabol123654
parabol123654 force-pushed the 18.0-fix-auditlog-patch-after-registry-loaded branch from 88e15f2 to 0c67685 Compare November 24, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants