Skip to content

Commit

Permalink
perf: defer holiday list imports
Browse files Browse the repository at this point in the history
Only used for configuring but loaded whenever
get_doc("holiday list", ...) is done
  • Loading branch information
ankush committed Aug 7, 2023
1 parent 10a2191 commit 2eea90a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions erpnext/setup/doctype/holiday_list/holiday_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from frappe import _, throw
from frappe.model.document import Document
from frappe.utils import formatdate, getdate, today
from holidays import country_holidays
from holidays.utils import list_supported_countries


class OverlapError(frappe.ValidationError):
Expand Down Expand Up @@ -39,6 +37,8 @@ def get_weekly_off_dates(self):

@frappe.whitelist()
def get_supported_countries(self):
from holidays.utils import list_supported_countries

subdivisions_by_country = list_supported_countries()
countries = [
{"value": country, "label": local_country_name(country)}
Expand All @@ -51,6 +51,8 @@ def get_supported_countries(self):

@frappe.whitelist()
def get_local_holidays(self):
from holidays import country_holidays

if not self.country:
throw(_("Please select a country"))

Expand Down

0 comments on commit 2eea90a

Please sign in to comment.