Merge pull request #5077 from frappe/master

Master
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 36a86ab..9ebc832 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
 from __future__ import unicode_literals
-__version__ = '6.27.3'
+__version__ = '6.27.5'
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 431675e..b4fe148 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -243,6 +243,8 @@
 		for p in pricing_rules:
 			if p.item_code and args.variant_of:
 				p.variant_of = args.variant_of
+			else:
+				p.variant_of = None
 
 	# find pricing rule with highest priority
 	if pricing_rules:
@@ -252,7 +254,7 @@
 
 	# apply internal priority
 	all_fields = ["item_code", "item_group", "brand", "customer", "customer_group", "territory",
-		"supplier", "supplier_type", "campaign", "sales_partner"]
+		"supplier", "supplier_type", "campaign", "sales_partner", "variant_of"]
 
 	if len(pricing_rules) > 1:
 		for field_set in [["item_code", "variant_of", "item_group", "brand"],
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 0ccc82a..04c81de 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -7,7 +7,7 @@
 app_description = """ERP made simple"""
 app_icon = "icon-th"
 app_color = "#e74c3c"
-app_version = "6.27.3"
+app_version = "6.27.5"
 app_email = "info@erpnext.com"
 app_license = "GNU General Public License (v3)"
 source_link = "https://github.com/frappe/erpnext"
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index db580f4..9e6afff 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -229,14 +229,13 @@
 		and status = 'Active'""", {"date": today()}, as_dict=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 = employee.holiday_list
+	holiday_list, company = frappe.db.get_value("Employee", employee, ["holiday_list", "company"])
 
 	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:
-		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
 
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 5bf7e9d..6882034 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -335,16 +335,14 @@
 
 
 def get_holidays(employee, from_date, to_date):
-	tot_hol = frappe.db.sql("""select count(*) from `tabHoliday` h1, `tabHoliday List` h2, `tabEmployee` e1
-		where e1.name = %s and h1.parent = h2.name and e1.holiday_list = h2.name
-		and h1.holiday_date between %s and %s""", (employee, from_date, to_date))[0][0]
+	'''get holidays between two dates for the given employee'''
+	holiday_list = get_holiday_list_for_employee(employee)
 
-	if not tot_hol:
-		tot_hol = 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
-			and h2.is_default = 1""", (from_date, to_date))[0][0]
+	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
+		and h2.name = %s""", (from_date, to_date, holiday_list))[0][0]
 
-	return tot_hol
+	return holidays
 
 def is_lwp(leave_type):
 	lwp = frappe.db.sql("select is_lwp from `tabLeave Type` where name = %s", leave_type)
diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py
index 0469972..5fab1ac 100644
--- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py
@@ -94,7 +94,11 @@
 		validated = False
 
 		employee = frappe.db.get_value("Sales Person", sales_person, "employee")
-		holiday_list = get_holiday_list_for_employee(employee)
+		if employee:
+			holiday_list = get_holiday_list_for_employee(employee)
+		else:
+			holiday_list = frappe.db.get_value("Company", self.company, "default_holiday_list")
+
 		holidays = frappe.db.sql_list('''select holiday_date from `tabHoliday` where parent=%s''', holiday_list)
 
 		if not validated and holidays:
diff --git a/setup.py b/setup.py
index bd41d1d..581e065 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 from pip.req import parse_requirements
 
-version = "6.27.3"
+version = "6.27.5"
 requirements = parse_requirements("requirements.txt", session="")
 
 setup(