diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py index 55d2468bc0..309e7e0f53 100644 --- a/erpnext/hr/doctype/holiday_list/holiday_list.py +++ b/erpnext/hr/doctype/holiday_list/holiday_list.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import frappe -from frappe.utils import cint, get_datetime +from frappe.utils import cint, getdate from frappe import throw, _ from frappe.model.document import Document @@ -59,7 +59,6 @@ class HolidayList(Document): def get_weekly_off_date_list(self, start_date, end_date): - from frappe.utils import getdate start_date, end_date = getdate(start_date), getdate(end_date) from dateutil import relativedelta @@ -71,8 +70,7 @@ class HolidayList(Document): weekday = getattr(calendar, (self.weekly_off).upper()) reference_date = start_date + relativedelta.relativedelta(weekday=weekday) - for holiday in self.get("holidays"): - existing_date_list.append(get_datetime(holiday.holiday_date).date()) + existing_date_list = [getdate(holiday.holiday_date) for holiday in self.get("holidays")] while reference_date <= end_date: if reference_date not in existing_date_list: diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py index d7ba1463d5..38a88c9074 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py @@ -90,35 +90,24 @@ class MaintenanceSchedule(TransactionBase): return schedule_list def validate_schedule_date_for_holiday_list(self, schedule_date, sales_person): - from erpnext.accounts.utils import get_fiscal_year validated = False - fy_details = "" - try: - fy_details = get_fiscal_year(date=schedule_date, verbose=0) - except Exception: - pass - - if fy_details and fy_details[0]: - # check holiday list in employee master - holiday_list = frappe.db.sql_list("""select h.holiday_date from `tabEmployee` emp, - `tabSales Person` sp, `tabHoliday` h, `tabHoliday List` hl - where sp.name=%s and emp.name=sp.employee - and hl.name=emp.holiday_list and - h.parent=hl.name and - hl.fiscal_year=%s""", (sales_person, fy_details[0])) - if not holiday_list: - # check global holiday list - holiday_list = frappe.db.sql("""select h.holiday_date from - `tabHoliday` h, `tabHoliday List` hl - where h.parent=hl.name and hl.is_default = 1 - and hl.fiscal_year=%s""", fy_details[0]) - - if not validated and holiday_list: - if schedule_date in holiday_list: - schedule_date = add_days(schedule_date, -1) - else: - validated = True + # check holiday list in employee master + holiday_list = frappe.db.sql_list("""select h.holiday_date from `tabEmployee` emp, + `tabSales Person` sp, `tabHoliday` h, `tabHoliday List` hl + where h.parent=hl.name and sp.name=%s and emp.name=sp.employee + and hl.name=emp.holiday_list + """, (sales_person)) + if not holiday_list: + # check global holiday list + holiday_list = frappe.db.sql_list("""select h.holiday_date from + `tabHoliday` h, `tabHoliday List` hl + where h.parent=hl.name and hl.is_default = 1""") + if not validated and holiday_list: + if schedule_date in holiday_list: + schedule_date = add_days(schedule_date, -1) + else: + validated = True return schedule_date