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

fix: sort holidays on save to avoid disorienting the user
This commit is contained in:
Rucha Mahabal
2024-07-09 14:56:25 +05:30
committed by GitHub
parent 0c76a8cc9e
commit ad137250fc

View File

@@ -43,6 +43,7 @@ class HolidayList(Document):
self.validate_days()
self.total_holidays = len(self.holidays)
self.validate_duplicate_date()
self.sort_holidays()
@frappe.whitelist()
def get_weekly_off_dates(self):
@@ -57,8 +58,6 @@ class HolidayList(Document):
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
@@ -100,8 +99,6 @@ class HolidayList(Document):
"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)):