feat: Ignore permlevel for specific fields #30686
Merged
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.
Current Behaviour:
Currently, if a field has a higher permlevel and a user does not have permission to that permlevel, on saving the document system resets the value of the field if there are any changes.
Solution:
There are some use-cases where the value of the field is changed by the code, not by the user. To allow those changes, introduced a document level flag to mention those specific fields for which permlevel will be ignored.
Actual Use Case:
In the ERPNext sales cycle, users want to set a higher permlevel for the price_list field because they want to control and it is set based on configuration.
On loading a transaction, the default value for price_list is set based on default_price_list set on Selling Settings. Then on the selection of Customers, it gets overwritten by the customer's default price list. But on saving the transaction, the system resets the price_list field's value to the original (system settings). This change will fix it.
Associated PR on the Frappe: frappe/frappe#16590
docs: no-docs