[fix] holiday_list issues in maintenance schedule too
This commit is contained in:
parent
51135a1522
commit
1b5edcbbd8
@ -229,14 +229,13 @@ def get_employees_who_are_born_today():
|
|||||||
and status = 'Active'""", {"date": today()}, as_dict=True)
|
and status = 'Active'""", {"date": today()}, as_dict=True)
|
||||||
|
|
||||||
def get_holiday_list_for_employee(employee, raise_exception=True):
|
def get_holiday_list_for_employee(employee, raise_exception=True):
|
||||||
employee = frappe.db.get_value("Employee", employee, ["holiday_list", "company"], as_dict=True)
|
holiday_list, company = frappe.db.get_value("Employee", employee, ["holiday_list", "company"])
|
||||||
holiday_list = employee.holiday_list
|
|
||||||
|
|
||||||
if not holiday_list:
|
if not holiday_list:
|
||||||
holiday_list = frappe.db.get_value("Company", employee.company, "default_holiday_list")
|
holiday_list = frappe.db.get_value("Company", company, "default_holiday_list")
|
||||||
|
|
||||||
if not holiday_list and raise_exception:
|
if not holiday_list and raise_exception:
|
||||||
frappe.throw(_("Please set a Holiday List for either the Employee or the Company"))
|
frappe.throw(_('Please set a default Holiday List for Employee {0} or Company {0}').format(employee, company))
|
||||||
|
|
||||||
return holiday_list
|
return holiday_list
|
||||||
|
|
||||||
|
|||||||
@ -336,22 +336,11 @@ def get_leave_allocation_records(date, employee=None):
|
|||||||
|
|
||||||
def get_holidays(employee, from_date, to_date):
|
def get_holidays(employee, from_date, to_date):
|
||||||
'''get holidays between two dates for the given employee'''
|
'''get holidays between two dates for the given employee'''
|
||||||
def get_from_holiday_list(from_date, to_date, holiday_list):
|
holiday_list = get_holiday_list_for_employee(employee)
|
||||||
return frappe.db.sql("""select count(distinct holiday_date) from `tabHoliday` h1, `tabHoliday List` h2
|
|
||||||
|
holidays = frappe.db.sql("""select count(distinct holiday_date) from `tabHoliday` h1, `tabHoliday List` h2
|
||||||
where h1.parent = h2.name and h1.holiday_date between %s and %s
|
where h1.parent = h2.name and h1.holiday_date between %s and %s
|
||||||
and h2.name = %s""", (from_date, to_date, default_holiday_list))[0][0]
|
and h2.name = %s""", (from_date, to_date, holiday_list))[0][0]
|
||||||
|
|
||||||
holiday_list, company = frappe.db.get_value('Employee', employee, ['holiday_list', 'company'])
|
|
||||||
if holiday_list:
|
|
||||||
holidays = get_from_holiday_list(from_date, to_date, holiday_list)
|
|
||||||
|
|
||||||
else:
|
|
||||||
default_holiday_list = frappe.db.get_value('Company', company, 'default_holiday_list')
|
|
||||||
|
|
||||||
if default_holiday_list:
|
|
||||||
holidays = get_from_holiday_list(from_date, to_date, default_holiday_list)
|
|
||||||
else:
|
|
||||||
frappe.throw(_('Please set a default holiday list for Employee {0} or Company {0}').format(employee, company))
|
|
||||||
|
|
||||||
return holidays
|
return holidays
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user