[19.0][FIX] Auditlog: Maximum recursion error when creating new accounts#3646
[19.0][FIX] Auditlog: Maximum recursion error when creating new accounts#3646hi-oerp wants to merge 1 commit into
Conversation
9f5f4c1 to
171695d
Compare
|
Good morning. @sebalix @StefanRijnhart @pedrobaeza @hbrunn Could you please help me validate this so we can proceed with the approval and merge? Thanks! |
StefanRijnhart
left a comment
There was a problem hiding this comment.
Thanks! Can you add a reproducing test to https://github.com/OCA/server-tools/tree/19.0/test_auditlog?
|
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. |
171695d to
d8e70a9
Compare
Hello @StefanRijnhart I created the tests to verify the infinite recursion issue. |
Hello @StefanRijnhart I have already verified the changes. Could you please regenerate the unit tests for the PR? Thanks! |
d8e70a9 to
4b27480
Compare
StefanRijnhart
left a comment
There was a problem hiding this comment.
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! |
4b27480 to
51c2adc
Compare
|
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! |
|
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. |
|
|
||
| def test_write_code_reentrancy(self): | ||
| """Regression test for recursive audit logging. | ||
| Ensures that writes triggered by computed/inverse fields (code/code_store) |
There was a problem hiding this comment.
What is code_store? Please mention account.account's _inverse_code / _compute_code literally.
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.