From fcf65001447b4f10459e69ca6f5d78b8a07ef34d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:44:08 +0530 Subject: [PATCH] fix(Holiday List): sort holidays on save to avoid disorienting the user (backport #42236) (#42251) * 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 ad137250fc8c9421fd085afd83ed439dcbbd0568) # Conflicts: # erpnext/setup/doctype/holiday_list/holiday_list.py * chore: fix conflicts --------- Co-authored-by: Rucha Mahabal --- erpnext/setup/doctype/holiday_list/holiday_list.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.py b/erpnext/setup/doctype/holiday_list/holiday_list.py index 94ec0b95675..4b51011c87d 100644 --- a/erpnext/setup/doctype/holiday_list/holiday_list.py +++ b/erpnext/setup/doctype/holiday_list/holiday_list.py @@ -19,6 +19,7 @@ class HolidayList(Document): def validate(self): self.validate_days() self.total_holidays = len(self.holidays) + self.sort_holidays() @frappe.whitelist() def get_weekly_off_dates(self): @@ -33,8 +34,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 @@ -76,8 +75,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)):