Merge pull request #16738 from deepeshgarg007/unique_tree_options
fix: Filter out unique values for tree options
This commit is contained in:
commit
e328869b10
@ -255,11 +255,16 @@ $.extend(erpnext.utils, {
|
||||
// get valid options for tree based on user permission & locals dict
|
||||
let unscrub_option = frappe.model.unscrub(option);
|
||||
let user_permission = frappe.defaults.get_user_permissions();
|
||||
let options;
|
||||
|
||||
if(user_permission && user_permission[unscrub_option]) {
|
||||
return user_permission[unscrub_option].map(perm => perm.doc);
|
||||
options = user_permission[unscrub_option].map(perm => perm.doc);
|
||||
} else {
|
||||
return $.map(locals[`:${unscrub_option}`], function(c) { return c.name; }).sort();
|
||||
options = $.map(locals[`:${unscrub_option}`], function(c) { return c.name; }).sort();
|
||||
}
|
||||
|
||||
// filter unique values, as there may be multiple user permissions for any value
|
||||
return options.filter((value, index, self) => self.indexOf(value) === index);
|
||||
},
|
||||
get_tree_default: function(option) {
|
||||
// set default for a field based on user permission
|
||||
|
Loading…
x
Reference in New Issue
Block a user