Skip to content

Commit

Permalink
fix(Holiday List): sort holidays on save to avoid disorienting the us…
Browse files Browse the repository at this point in the history
…er (backport #42236) (#42250)

fix(Holiday List): sort holidays on save to avoid disorienting the user (#42236)

fix: sort holidays on save to avoid disorienting the user
(cherry picked from commit ad13725)

Co-authored-by: Rucha Mahabal <[email protected]>
  • Loading branch information
mergify[bot] and ruchamahabal authored Jul 9, 2024
1 parent 2deea33 commit b555615
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions erpnext/setup/doctype/holiday_list/holiday_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def validate(self):
self.validate_days()
self.total_holidays = len(self.holidays)
self.validate_duplicate_date()
self.sort_holidays()

@frappe.whitelist()
def get_weekly_off_dates(self):
Expand All @@ -57,8 +58,6 @@ def get_weekly_off_dates(self):

self.append("holidays", {"description": _(self.weekly_off), "holiday_date": d, "weekly_off": 1})

self.sort_holidays()

@frappe.whitelist()
def get_supported_countries(self):
from holidays.utils import list_supported_countries
Expand Down Expand Up @@ -100,8 +99,6 @@ def get_local_holidays(self):
"holidays", {"description": holiday_name, "holiday_date": holiday_date, "weekly_off": 0}
)

self.sort_holidays()

def sort_holidays(self):
self.holidays.sort(key=lambda x: getdate(x.holiday_date))
for i in range(len(self.holidays)):
Expand Down

0 comments on commit b555615

Please sign in to comment.