From 9e8bb9b235f6723b28fe0568915ee52ed2e52262 Mon Sep 17 00:00:00 2001 From: Anjali Patel Date: Wed, 13 Aug 2025 09:33:54 +0000 Subject: [PATCH] fix: prevent self in "Reports To" dropdown (UI-level check) Ensures employee cannot select themselves in the "Reports To" field via UI. This complements server-side validation by improving UX. (cherry picked from commit 608d38a172ef20f2b44c6a2b0d5032406d1f5947) --- erpnext/setup/doctype/employee/employee.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/employee/employee.js b/erpnext/setup/doctype/employee/employee.js index 2e45d5511b3..d245935d715 100755 --- a/erpnext/setup/doctype/employee/employee.js +++ b/erpnext/setup/doctype/employee/employee.js @@ -11,7 +11,13 @@ erpnext.setup.EmployeeController = class EmployeeController extends frappe.ui.fo }; }; this.frm.fields_dict.reports_to.get_query = function (doc, cdt, cdn) { - return { query: "erpnext.controllers.queries.employee_query" }; + // return { query: "erpnext.controllers.queries.employee_query" }; + return { + filters: [ + ["status", "=", "Active"], // only active employees + ["name", "!=", doc.name] // exclude self + ] + }; }; }