Skip to content

Commit 8ca02e7

Browse files
authored
Merge pull request #50538 from asmitahase/holiday-list-assignment
2 parents 60f8654 + 7362d78 commit 8ca02e7

File tree

5 files changed

+67
-8
lines changed

5 files changed

+67
-8
lines changed

erpnext/setup/doctype/employee/employee.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ def get_employee_email(employee_doc):
254254
)
255255

256256

257-
def get_holiday_list_for_employee(employee, raise_exception=True):
257+
def get_holiday_list_for_employee(employee, raise_exception=True, as_on=None):
258+
hrms_override = frappe.get_hooks("employee_holiday_list")
259+
260+
if hrms_override:
261+
return frappe.get_attr(hrms_override[-1])(employee, raise_exception, as_on)
258262
if employee:
259263
holiday_list, company = frappe.get_cached_value("Employee", employee, ["holiday_list", "company"])
260264
else:

erpnext/setup/doctype/holiday/holiday.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
"column_break_2",
1111
"weekly_off",
1212
"section_break_4",
13-
"description"
13+
"description",
14+
"is_half_day"
1415
],
1516
"fields": [
1617
{
18+
"columns": 2,
1719
"fieldname": "holiday_date",
1820
"fieldtype": "Date",
1921
"in_list_view": 1,
@@ -23,6 +25,7 @@
2325
"reqd": 1
2426
},
2527
{
28+
"columns": 3,
2629
"fieldname": "description",
2730
"fieldtype": "Text Editor",
2831
"in_list_view": 1,
@@ -32,6 +35,7 @@
3235
"width": "300px"
3336
},
3437
{
38+
"columns": 2,
3539
"default": "0",
3640
"fieldname": "weekly_off",
3741
"fieldtype": "Check",
@@ -44,18 +48,28 @@
4448
{
4549
"fieldname": "section_break_4",
4650
"fieldtype": "Section Break"
51+
},
52+
{
53+
"columns": 2,
54+
"default": "0",
55+
"fieldname": "is_half_day",
56+
"fieldtype": "Check",
57+
"in_list_view": 1,
58+
"in_preview": 1,
59+
"label": "Is Half Day"
4760
}
4861
],
4962
"idx": 1,
5063
"istable": 1,
5164
"links": [],
52-
"modified": "2024-03-27 13:09:49.810408",
65+
"modified": "2025-08-28 15:15:44.177181",
5366
"modified_by": "Administrator",
5467
"module": "Setup",
5568
"name": "Holiday",
5669
"owner": "Administrator",
5770
"permissions": [],
71+
"row_format": "Dynamic",
5872
"sort_field": "creation",
5973
"sort_order": "ASC",
6074
"states": []
61-
}
75+
}

erpnext/setup/doctype/holiday/holiday.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Holiday(Document):
1616

1717
description: DF.TextEditor
1818
holiday_date: DF.Date
19+
is_half_day: DF.Check
1920
parent: DF.Data
2021
parentfield: DF.Data
2122
parenttype: DF.Data

erpnext/setup/doctype/holiday_list/holiday_list.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"add_weekly_holidays",
1717
"weekly_off",
1818
"get_weekly_off_dates",
19+
"column_break_euok",
20+
"is_half_day",
1921
"add_local_holidays",
2022
"country",
2123
"subdivision",
@@ -136,12 +138,22 @@
136138
"fieldtype": "Button",
137139
"label": "Add to Holidays",
138140
"options": "get_local_holidays"
141+
},
142+
{
143+
"fieldname": "column_break_euok",
144+
"fieldtype": "Column Break"
145+
},
146+
{
147+
"default": "0",
148+
"fieldname": "is_half_day",
149+
"fieldtype": "Check",
150+
"label": "Is Half Day"
139151
}
140152
],
141153
"icon": "fa fa-calendar",
142154
"idx": 1,
143155
"links": [],
144-
"modified": "2024-03-27 13:09:49.920245",
156+
"modified": "2025-08-28 15:17:05.313383",
145157
"modified_by": "Administrator",
146158
"module": "Setup",
147159
"name": "Holiday List",
@@ -160,7 +172,8 @@
160172
"write": 1
161173
}
162174
],
175+
"row_format": "Dynamic",
163176
"sort_field": "creation",
164177
"sort_order": "DESC",
165178
"states": []
166-
}
179+
}

erpnext/setup/doctype/holiday_list/holiday_list.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class HolidayList(Document):
3131
from_date: DF.Date
3232
holiday_list_name: DF.Data
3333
holidays: DF.Table[Holiday]
34+
is_half_day: DF.Check
3435
subdivision: DF.Autocomplete | None
3536
to_date: DF.Date
3637
total_holidays: DF.Int
@@ -56,7 +57,15 @@ def get_weekly_off_dates(self):
5657
if d in existing_holidays:
5758
continue
5859

59-
self.append("holidays", {"description": _(self.weekly_off), "holiday_date": d, "weekly_off": 1})
60+
self.append(
61+
"holidays",
62+
{
63+
"description": _(self.weekly_off),
64+
"holiday_date": d,
65+
"weekly_off": 1,
66+
"is_half_day": self.is_half_day,
67+
},
68+
)
6069

6170
@frappe.whitelist()
6271
def get_supported_countries(self):
@@ -194,7 +203,25 @@ def is_holiday(holiday_list, date=None):
194203
if date is None:
195204
date = today()
196205
if holiday_list:
197-
return bool(frappe.db.exists("Holiday", {"parent": holiday_list, "holiday_date": date}, cache=True))
206+
return bool(
207+
frappe.db.exists(
208+
"Holiday", {"parent": holiday_list, "holiday_date": date, "is_half_day": 0}, cache=True
209+
)
210+
)
211+
else:
212+
return False
213+
214+
215+
def is_half_holiday(holiday_list, date=None):
216+
"""Returns true if the given date is a half holiday in the given holiday list"""
217+
if date is None:
218+
date = today()
219+
if holiday_list:
220+
return bool(
221+
frappe.db.exists(
222+
"Holiday", {"parent": holiday_list, "holiday_date": date, "is_half_day": 1}, cache=True
223+
)
224+
)
198225
else:
199226
return False
200227

0 commit comments

Comments
 (0)