Skip to content

[19.0][FIX] Auditlog: Maximum recursion error when creating new accounts#3646

Open
hi-oerp wants to merge 1 commit into
OCA:19.0from
oerp-canada:19.0-fix-auditlog
Open

[19.0][FIX] Auditlog: Maximum recursion error when creating new accounts#3646
hi-oerp wants to merge 1 commit into
OCA:19.0from
oerp-canada:19.0-fix-auditlog

Conversation

@hi-oerp

@hi-oerp hi-oerp commented Jun 9, 2026

Copy link
Copy Markdown

Module

Auditlog

Describe the bug

Maximum recursion error when creating new accounts

To Reproduce

Create a new rule for the account.account module
Check "Log Creates", "Log Writes" and "Full Log" in the new rule

Steps to reproduce the behavior:

Go to Accounting -> Configuration -> Chart of Account
Create a new account with code
Foreve loading and "RecursionError: maximum recursion depth exceeded"

Expected behavior
It should be able to save

Additional context
In Odoo, there are 2 methods in the AccountAccount class called _compute_code and _inverse_code.
Auditlog module keeps triggering these 2 methods and causing an infinite loop.

@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch 2 times, most recently from 9f5f4c1 to 171695d Compare June 10, 2026 13:43
@hi-oerp

hi-oerp commented Jun 17, 2026

Copy link
Copy Markdown
Author

Good morning.

@sebalix @StefanRijnhart @pedrobaeza @hbrunn Could you please help me validate this so we can proceed with the approval and merge?

Thanks!

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you add a reproducing test to https://github.com/OCA/server-tools/tree/19.0/test_auditlog?

@StefanRijnhart

Copy link
Copy Markdown
Member

If you check the failing tests, it looks like your changes prevent some other expected logs to be created, so it's not all well.

@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch from 171695d to d8e70a9 Compare June 29, 2026 13:45
@OCA-git-bot OCA-git-bot added the mod:test_auditlog Module test_auditlog label Jun 29, 2026
@hi-oerp

hi-oerp commented Jun 29, 2026

Copy link
Copy Markdown
Author

Thanks! Can you add a reproducing test to https://github.com/OCA/server-tools/tree/19.0/test_auditlog?

Hello @StefanRijnhart I created the tests to verify the infinite recursion issue.

@hi-oerp

hi-oerp commented Jun 29, 2026

Copy link
Copy Markdown
Author

If you check the failing tests, it looks like your changes prevent some other expected logs to be created, so it's not all well.

Hello @StefanRijnhart I have already verified the changes. Could you please regenerate the unit tests for the PR?

Thanks!

@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch from d8e70a9 to 4b27480 Compare June 29, 2026 20:24

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Nice work on building an actual recursion prevention mechanism. However, I don't think we need to resort to manipulating threads but instead add the auditlog_guard dictionary to the context. Because it is an editable, it can still be updated in nested calls. Would you mind refactoring it?

Comment thread auditlog/models/auditlog_rule.py
Comment thread test_auditlog/tests/test_account_reentrancy.py
@hi-oerp

hi-oerp commented Jun 30, 2026

Copy link
Copy Markdown
Author

Thanks! Nice work on building an actual recursion prevention mechanism. However, I don't think we need to resort to manipulating threads but instead add the auditlog_guard dictionary to the context. Because it is an editable, it can still be updated in nested calls. Would you mind refactoring it?

Thank you very much. @StefanRijnhart

As a first approach, I tried implementing this using the context, but in some cases the context is lost, which causes the recursion issue to reappear. I also attempted to pass the control flag through the transaction, but the recursion continue.

As a last resort, I had to implement the guard using a thread variable.

Note: If this solution is acceptable, I will also need to apply the same implementation to the fast log.

Thanks in advance!

@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch from 4b27480 to 51c2adc Compare June 30, 2026 18:55
@hi-oerp

hi-oerp commented Jun 30, 2026

Copy link
Copy Markdown
Author

Hello @StefanRijnhart I have pushed the latest changes. I also added the context used to skip the read operation.

Please let me know if you have any comments or suggestions. Thank you very much for your feedback!

@StefanRijnhart

Copy link
Copy Markdown
Member

Can you be more specific under which the context gets lost? I have a POC here locally with the guard in the context and the test still succeeds.

Comment thread test_auditlog/tests/test_account_reentrancy.py Outdated
@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch from 51c2adc to e3ed1af Compare July 14, 2026 14:43
@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch from e3ed1af to a85adb9 Compare July 14, 2026 14:48
@hi-oerp

hi-oerp commented Jul 14, 2026

Copy link
Copy Markdown
Author

Hello @StefanRijnhart

Thank you very much for the code review. I've addressed all the requested changes.

Could you please take another look? If everything looks good, I'd appreciate it if you could proceed with the integration. Once it's merged, I'll be able to close the remaining ticket I have for this module.

See you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:auditlog Module auditlog mod:test_auditlog Module test_auditlog series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants