perf: defer holiday list imports
Only used for configuring but loaded whenever get_doc("holiday list", ...) is done
This commit is contained in:
parent
10a2191e3f
commit
2eea90a873
@ -9,8 +9,6 @@ import frappe
|
|||||||
from frappe import _, throw
|
from frappe import _, throw
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import formatdate, getdate, today
|
from frappe.utils import formatdate, getdate, today
|
||||||
from holidays import country_holidays
|
|
||||||
from holidays.utils import list_supported_countries
|
|
||||||
|
|
||||||
|
|
||||||
class OverlapError(frappe.ValidationError):
|
class OverlapError(frappe.ValidationError):
|
||||||
@ -39,6 +37,8 @@ class HolidayList(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_supported_countries(self):
|
def get_supported_countries(self):
|
||||||
|
from holidays.utils import list_supported_countries
|
||||||
|
|
||||||
subdivisions_by_country = list_supported_countries()
|
subdivisions_by_country = list_supported_countries()
|
||||||
countries = [
|
countries = [
|
||||||
{"value": country, "label": local_country_name(country)}
|
{"value": country, "label": local_country_name(country)}
|
||||||
@ -51,6 +51,8 @@ class HolidayList(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_local_holidays(self):
|
def get_local_holidays(self):
|
||||||
|
from holidays import country_holidays
|
||||||
|
|
||||||
if not self.country:
|
if not self.country:
|
||||||
throw(_("Please select a country"))
|
throw(_("Please select a country"))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user