Filter List View Items

Hi is it possible to make a permission to view document based on the reports_to / department from the employee doctype
Emp A is in sales Dept
only other users that on sales dept can view the Emp A data
What are the settings for this scenario?

I use this on employee custom script but to no avail it still show all department

frappe.listview_settings[‘Employee’] = {
onload: function(listview) {
if (!frappe.route_options){
frappe.route_options = {
“department”: [“=”, “frappe.session.user.department”]


This can be done using User Permissions. Check this link: User Permissions

Hope this helps.