Skip to content

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

Merged
OCA-git-bot merged 1 commit into
OCA:19.0from
oerp-canada:19.0-fix-auditlog
Jul 28, 2026
Merged

[19.0][FIX] auditlog: Maximum recursion error when creating new accounts#3646
OCA-git-bot merged 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 2 times, most recently 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!

@hi-oerp

hi-oerp commented Jul 22, 2026

Copy link
Copy Markdown
Author

Hello @StefanRijnhart , Could you please validate whether it is possible to merge this PR?

Thank you in advance!

@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, looking good!

@StefanRijnhart StefanRijnhart changed the title [19.0][FIX] Auditlog: Maximum recursion error when creating new accounts [19.0][FIX] auditlog: Maximum recursion error when creating new accounts Jul 26, 2026
@pedrobaeza pedrobaeza added this to the 19.0 milestone Jul 27, 2026

@pedrobaeza pedrobaeza 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.

Can you remove [19.0] from the commit message?

Comment thread auditlog/models/auditlog_rule.py Outdated
@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch 2 times, most recently from ed3f891 to 98dfa96 Compare July 27, 2026 12:59
@hi-oerp hi-oerp changed the title [19.0][FIX] auditlog: Maximum recursion error when creating new accounts [FIX] auditlog: Maximum recursion error when creating new accounts Jul 27, 2026
@hi-oerp

hi-oerp commented Jul 27, 2026

Copy link
Copy Markdown
Author

Hello @pedrobaeza , The recommendations were implemented!

Thank you!

@pedrobaeza pedrobaeza changed the title [FIX] auditlog: Maximum recursion error when creating new accounts [19.0][FIX] auditlog: Maximum recursion error when creating new accounts Jul 27, 2026
@hi-oerp
hi-oerp force-pushed the 19.0-fix-auditlog branch from 98dfa96 to a7b6689 Compare July 27, 2026 15:59
@hi-oerp hi-oerp changed the title [19.0][FIX] auditlog: Maximum recursion error when creating new accounts [FIX] auditlog: Maximum recursion error when creating new accounts Jul 27, 2026
@pedrobaeza pedrobaeza changed the title [FIX] auditlog: Maximum recursion error when creating new accounts [19.0][FIX] auditlog: Maximum recursion error when creating new accounts Jul 27, 2026
@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@StefanRijnhart

Copy link
Copy Markdown
Member

Making major version bump to signal the modified context key name.

/ocabot merge major

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 19.0-ocabot-merge-pr-3646-by-StefanRijnhart-bump-major, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 947d7cf into OCA:19.0 Jul 28, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at ffc2d08. Thanks a lot for contributing to OCA. ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants