Urgent -Employee Permission Issue

out is

In [1]: print(frappe.get_hooks(“has_permission”))
{‘Event’: [‘frappe.desk.doctype.event.event.has_permission’], ‘ToDo’: [‘frappe.desk.doctype.todo.todo.has_permission’], ‘Note’: [‘frappe.desk.doctype.note.note.has_permission’], ‘User’: [‘frappe.core.doctype.user.user.has_permission’], ‘Dashboard Chart’: [‘frappe.desk.doctype.dashboard_chart.dashboard_chart.has_permission’], ‘Number Card’: [‘frappe.desk.doctype.number_card.number_card.has_permission’], ‘Kanban Board’: [‘frappe.desk.doctype.kanban_board.kanban_board.has_permission’], ‘Contact’: [‘frappe.contacts.address_and_contact.has_permission’], ‘Address’: [‘frappe.contacts.address_and_contact.has_permission’], ‘Communication’: [‘frappe.core.doctype.communication.communication.has_permission’], ‘Workflow Action’: [‘frappe.workflow.doctype.workflow_action.workflow_action.has_permission’], ‘File’: [‘frappe.core.doctype.file.file.has_permission’], ‘Prepared Report’: [‘frappe.core.doctype.prepared_report.prepared_report.has_permission’], ‘Notification Settings’: [‘frappe.desk.doctype.notification_settings.notification_settings.has_permission’], ‘User Invitation’: [‘frappe.core.doctype.user_invitation.user_invitation.has_permission’], ‘Employee’: [‘custom_app.overrides.permission.has_permission’]}

I have follow above process but not work can you give me code please

in my coustom app i have below code

def has_permission(doc, ptype, user):
“”"
Explicitly return True for v16 compatibility.
In v16, returning None is treated as False (denied).
“”"
# Allow employee to access their own record
employee_user = frappe.db.get_value(“Employee”, doc.name, “user_id”)
if employee_user == user:
return True

# Allow HR roles full access
user_roles = frappe.get_roles(user)
if any(role in user_roles for role in ["HR Manager", "HR User", "System Manager"]):
    return True

# Must explicitly return True (not None) for v16
return True

has_permission = {
“Employee”: “custom_app.custom_app.employee.has_permission”
}

After Updating Version from 15 to 16 You Migrate The Bench?

yes i have migrate bench

can you check this code is ok?

Here You have to give path of your function in hooks where you define that function

in custom_app both code and hook aslo in custom-app

You Override the Employee Doctype Code or Permission Anything in Your Custom App?

Yes i have use this code to overide has_permission but not work

No I am saying before doing this is in your custom_app has some permission add on or employee doctype customization or not?

let me check
has_permission is not added as of before installation.
but i have added role based permission on employee doctype . it create issue?

Example of Permissions?

like if user is employee role hidden some fields . but this client script i have disable issue is not solve.

No I am talking about role permission changes through role permission manager.

Also Please Check is Any Link Field in Employee Doctype which user have not role Permission and also in Employee Doctype Permission “Only If Creator” not checked

1 Like

Thnaks for your guidence . we have employee history there is report to field is link.

What is the issue exactly?
And Employee History is Default Doctype or you are talking about logs in Employee Record?

Issue is we have custom child table in employee link with employee (report-to manager) this create issue

All good, just don’t call me Sir :grinning_face_with_smiling_eyes:

1 Like