From a56ce87f328a701a9ace878fe25ea6ee3f0717bb Mon Sep 17 00:00:00 2001 From: MOHAMMED NIYAS <76736615+niyazrazak@users.noreply.github.com> Date: Fri, 16 Jun 2023 10:25:49 +0300 Subject: [PATCH] fix: share submit permission self (#590) While creating a leave application, if the employee doesn't have a leave approver set, the document is shared with the leave applicant himself by the share API as the approver is `None`. The Applicant ends up getting submit permission for leave application accidentally but cannot submit it as the "status" field is read-only and has perm level set. Video: https://github.com/frappe/hrms/assets/76736615/580b6ceb-9881-4801-b422-9e428ccf15f3 (cherry picked from commit eec8f4308ed0a1087bd5c129e4dc0c5af27404da) --- hrms/hr/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hrms/hr/utils.py b/hrms/hr/utils.py index 727a5d5467..d5a42f2fc7 100644 --- a/hrms/hr/utils.py +++ b/hrms/hr/utils.py @@ -643,6 +643,9 @@ def get_previous_claimed_amount(employee, payroll_period, non_pro_rata=False, co def share_doc_with_approver(doc, user): + if not user: + return + # if approver does not have permissions, share if not frappe.has_permission(doc=doc, ptype="submit", user=user): frappe.share.add_docshare(