perf: cache and simplify queries for holiday list (#35315)
diff --git a/erpnext/setup/doctype/employee/employee.py b/erpnext/setup/doctype/employee/employee.py
index ece5a7d..566392c 100755
--- a/erpnext/setup/doctype/employee/employee.py
+++ b/erpnext/setup/doctype/employee/employee.py
@@ -257,7 +257,9 @@
def get_holiday_list_for_employee(employee, raise_exception=True):
if employee:
- holiday_list, company = frappe.db.get_value("Employee", employee, ["holiday_list", "company"])
+ holiday_list, company = frappe.get_cached_value(
+ "Employee", employee, ["holiday_list", "company"]
+ )
else:
holiday_list = ""
company = frappe.db.get_single_value("Global Defaults", "default_company")
diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.py b/erpnext/setup/doctype/holiday_list/holiday_list.py
index fad827a..84d0d35 100644
--- a/erpnext/setup/doctype/holiday_list/holiday_list.py
+++ b/erpnext/setup/doctype/holiday_list/holiday_list.py
@@ -115,6 +115,8 @@
if date is None:
date = today()
if holiday_list:
- return bool(frappe.get_all("Holiday List", dict(name=holiday_list, holiday_date=date)))
+ return bool(
+ frappe.db.exists("Holiday", {"parent": holiday_list, "holiday_date": date}, cache=True)
+ )
else:
return False