[15.0][FIX] auditlog rule: Control the write function in the models when executed by an onchange function #2912
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes to fix the following issue: #2343
The goal of these changes is to fix the issue that when you activate the audit rule for the products, and then you try to create or modify the price, an access error appears.
From what I've been able to see, this is because in version 15 added the onchange decorator in the _set_product_lst_price function. As within this function a write is being executed for the same product. This causes it to go through the logic of the AuditlogRule with an object that has the id as "NewId". Causing the error to appear when checking the security rules.
I've modified the AuditlogRule class and modify the _make_write function, where inside there, I check if the record id is an object that instance of NewId. If instance of NewId, What it does is ignore the original logic to prevent it from executing the read function. It'll only run the write_full.origin to do the base logic. If this is not the case, and it's a normal id, it'll execute the usual logic.