frappe / frappe

Low code web framework for real world applications, in Python and Javascript
https://frappeframework.com
MIT License
7.02k stars 3.35k forks source link

apply depends on or custom script on report builder #9983

Closed mohamedesmail235 closed 7 months ago

mohamedesmail235 commented 4 years ago

Description of the issue

I have created custom field named item_cost in Item doctype and make custom script to toggle display it depends on role permission and i use this script

frappe.ui.form.on('Item', {
    setup:function(frm) {
        function is_subset(list_a, list_b) {
            return list_a.every(function (item) { return list_b.includes(item); });
        }
        frm.toggle_display('item_cost',(is_subset(['System Manager'], frappe.user_roles)))
    }
})

and when users that don't have permission to see such field make report builder and pick column they can see such field and print it I alse use this line condition in depends_on field of that custom filed and in vain eval:!doc.__islocal && in_list(frappe.user_roles, "System Manager")

Expected result

i hope custom script or depends_on conditions apply on fields in doctypes and report builder as well

OS version / distribution, Frappe install method, etc.

ankush commented 7 months ago

For this particular use case you can just use perm level to hide it instead of writing JS for it.