Fixes
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 9ff02b2..2783391 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -137,7 +137,12 @@
 			and (from_date between %(from_date)s and %(to_date)s
 				or to_date between %(from_date)s and %(to_date)s
 				or %(from_date)s between from_date and to_date)
-			and name != %(name)s""", self.as_dict(), as_dict = 1):
+			and name != %(name)s""", {
+				"employee": self.employee,
+				"from_date": self.from_date,
+				"to_date": self.to_date,
+				"name": self.name
+			}, as_dict = 1):
 
 			frappe.msgprint(_("Employee {0} has already applied for {1} between {2} and {3}").format(self.employee,
 				cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date'])))
diff --git a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py b/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py
index 5f9fc23..fa35898 100644
--- a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py
+++ b/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py
@@ -14,6 +14,9 @@
 
 	for d in frappe.db.sql("""select * from `tabCustomer Discount`
 		where ifnull(parent, '') != ''""", as_dict=1):
+			if not d.discount:
+				continue
+
 			frappe.get_doc({
 				"doctype": "Pricing Rule",
 				"apply_on": "Item Group",
diff --git a/erpnext/templates/generators/item_group.py b/erpnext/templates/generators/item_group.py
index fab581c..8e09dbc 100644
--- a/erpnext/templates/generators/item_group.py
+++ b/erpnext/templates/generators/item_group.py
@@ -44,7 +44,7 @@
 	item_group = frappe.get_doc("Item Group", item_group_name)
 	return frappe.db.sql("""select name
 		from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
-			and show_in_website = 1""", item_group.as_dict())
+			and show_in_website = 1""", {"lft": item_group.lft, "rgt": item_group.rgt})
 
 def get_item_for_list_in_html(context):
 	return frappe.get_template("templates/includes/product_in_grid.html").render(context)