From 6203ffc8fab9a6061b991fa689c73391d1671cdf Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 7 Apr 2022 10:06:51 +0530 Subject: [PATCH] fix: make New Leaves Allocated read-only if policy assignment is linked to the allocation and leave type is earned leave --- erpnext/hr/doctype/leave_allocation/leave_allocation.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.js b/erpnext/hr/doctype/leave_allocation/leave_allocation.js index 9742387c16..aef4412251 100755 --- a/erpnext/hr/doctype/leave_allocation/leave_allocation.js +++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.js @@ -34,6 +34,15 @@ frappe.ui.form.on("Leave Allocation", { }); } } + + // make new leaves allocated field read only if allocation is created via leave policy assignment + // and leave type is earned leave, since these leaves would be allocated via the scheduler + if (frm.doc.leave_policy_assignment) { + frappe.db.get_value("Leave Type", frm.doc.leave_type, "is_earned_leave", (r) => { + if (r && cint(r.is_earned_leave)) + frm.set_df_property("new_leaves_allocated", "read_only", 1); + }); + } }, expire_allocation: function(frm) {