Cannot delete Auditlog Rules
Module
Auditlog
Describe the bug
An error is triggered when trying to delete an Auditlog Rule, this error isn't always triggered and is quite inconsistent. The suspected cause is the deletion of the attrs added in the "_patch_methods" call, like "auditlog_ruled_create", that is done in the "_revert_methods" call with:
- delattr(type(model_model), "auditlog_ruled_%s" % method)
And resulting in the following error message:
Traceback (most recent call last):
File "/home/odoo/repos/odoo/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/repos/odoo/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
AttributeError: auditlog_ruled_unlink
To Reproduce
Affected versions: We could reproduce this on Odoo v14 and v15, other versions might be affected as well.
Steps to reproduce the behavior:
- Create an Audit Rule
- Attempt to delete it.
- Sometimes the above mentioned error is triggered.
Expected behavior The Rule is deleted with no errors (the added attributes are removed accordingly).
Further info regarding this issue: The new attributes were created through sudo(), if the delattr() is called with self.sudo() as well the deletion doesn't trigger an error anymore.
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.