I want to hide draft record

i want to hide those recored whose status is draft from others

its should be visible to the employee who is created not to others

u can write permission query for that so set permission query for that using the sql query condition

When creating an Employee, there is a User Permission [sic] document that is created that is used to restrict one user to specific documents.

@Meet i am writing this but its adding in filter and data also not as i am expecting

frappe.listview_settings[‘Timesheet’] = {
onload: function(listview) {
if (!frappe.user.has_role(‘System Manager’)) { // System Manager or any role you want to exclude from this filtering
listview.filter_area.add([[listview.doctype, ‘owner’, ‘=’, frappe.session.user]]);
listview.filter_area.add([[listview.doctype, ‘status’, ‘!=’, ‘Draft’]]);
}
}
};

i want to hide when doc status is draft, it should visible to employee only

There are HUGE security risks in filtering using only JavaScript.

You might want to take a look at the User Permission and Permission Manager doctypes/pages.

Users and Permissions

i want to hide whose status is draft only from others

U can write python function and add in the hooks file for permission query

def timesheet permission(self):
     condition = ""
     # Write your role condition
     if role:
        return condition
     else:
        condition += "doc.status != 0 or doc.owner = self.user"
        return condition

@Meet i am unable to create hooks.py file

when i am creating custum app and installing in my site then “no module found error” is coming

so i want to try via script

Using from server script try it if your query resolved else use custom app code your condition possible else not possible

1 Like

@Prashanth_Kolhetkar add this in server script

user = frappe.session.user
employee = frappe.db.get_value(‘Employee’,{“user_id”:frappe.session.user},‘name’)
if employee :
conditions = “owner = '” + user + “’ OR employee= '” + employee + “'”