Merge branch 'hotfix'
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 8177c29..6018a4c 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.0.38'
+__version__ = '7.0.39'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 4578f30..695a721 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -226,6 +226,12 @@
 
 	party: function(frm) {
 		if(frm.doc.payment_type && frm.doc.party_type && frm.doc.party) {
+			if(!frm.doc.posting_date) {
+				frappe.msgprint(__("Please select Posting Date before selecting Party"))
+				frm.set_value("party", "");
+				return ;
+			}
+			
 			frm.set_party_account_based_on_party = true;
 
 			return frappe.call({
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json
index 43d43ca..2057d07 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.json
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json
@@ -75,7 +75,7 @@
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
-   "in_list_view": 0, 
+   "in_list_view": 1, 
    "label": "Payment Type", 
    "length": 0, 
    "no_copy": 0, 
@@ -1426,7 +1426,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-09-02 11:34:14.817383", 
+ "modified": "2016-09-05 11:06:18.183458", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Payment Entry", 
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry_list.js b/erpnext/accounts/doctype/payment_entry/payment_entry_list.js
deleted file mode 100644
index 81230d0..0000000
--- a/erpnext/accounts/doctype/payment_entry/payment_entry_list.js
+++ /dev/null
@@ -1,6 +0,0 @@
-frappe.listview_settings['Payment Entry'] = {
-	add_fields: ["payment_type"],
-	get_indicator: function(doc) {
-		return [__(doc.payment_type), (doc.docstatus==0 ? 'red' : 'blue'), 'status=' + doc.payment_type]
-	}
-}
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 0debe4a..6da496b 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -17,7 +17,8 @@
 				if isinstance(f[1], basestring) and f[1][0] == '!':
 					flt.append([doctype, f[0], '!=', f[1][1:]])
 				else:
-					flt.append([doctype, f[0], '=', f[1]])
+					value = frappe.db.escape(f[1]) if isinstance(f[1], basestring) else f[1]
+					flt.append([doctype, f[0], '=', value])
 
 		query = DatabaseQuery(doctype)
 		query.filters = flt
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
index 4cbccaf..5f82967 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
@@ -58,7 +58,7 @@
 			if no_email_sp:
 				frappe.msgprint(
 					frappe._("Setting Events to {0}, since the Employee attached to the below Sales Persons does not have a User ID{1}").format(
-						self.owner, "<br>"+no_email_sp.join("<br>")
+						self.owner, "<br>" + "<br>".join(no_email_sp)
 				))
 
 			scheduled_date = frappe.db.sql("""select scheduled_date from
@@ -187,14 +187,17 @@
 			if not sr_details:
 				frappe.throw(_("Serial No {0} not found").format(serial_no))
 
-			if sr_details.warranty_expiry_date and sr_details.warranty_expiry_date>=amc_start_date:
-				throw(_("Serial No {0} is under warranty upto {1}").format(serial_no, sr_details.warranty_expiry_date))
+			if sr_details.warranty_expiry_date \
+				and getdate(sr_details.warranty_expiry_date) >= getdate(amc_start_date):
+				throw(_("Serial No {0} is under warranty upto {1}")
+					.format(serial_no, sr_details.warranty_expiry_date))
 
-			if sr_details.amc_expiry_date and sr_details.amc_expiry_date >= amc_start_date:
-				throw(_("Serial No {0} is under maintenance contract upto {1}").format(serial_no, sr_details.amc_start_date))
+			if sr_details.amc_expiry_date and getdate(sr_details.amc_expiry_date) >= getdate(amc_start_date):
+				throw(_("Serial No {0} is under maintenance contract upto {1}")
+					.format(serial_no, sr_details.amc_start_date))
 
 			if not sr_details.warehouse and sr_details.delivery_date and \
-				sr_details.delivery_date >= amc_start_date:
+				getdate(sr_details.delivery_date) >= getdate(amc_start_date):
 					throw(_("Maintenance start date can not be before delivery date for Serial No {0}")
 						.format(serial_no))
 
diff --git a/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py b/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py
index ab0b4a1..cc854a4 100644
--- a/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py
+++ b/erpnext/projects/report/daily_timesheet_summary/daily_timesheet_summary.py
@@ -12,8 +12,9 @@
 		filters["from_time"] = "00:00:00"
 		filters["to_time"] = "24:00:00"
 
-	columns = [_("Timesheet") + ":Link/Timesheet:120", _("Employee") + "::150", _("From Datetime") + "::140",
-		_("To Datetime") + "::140", _("Hours") + "::70", _("Activity Type") + "::120", _("Task") + ":Link/Task:150",
+	columns = [_("Timesheet") + ":Link/Timesheet:120", _("Employee") + "::150", _("Employee Name") + "::150", 
+		_("From Datetime") + "::140", _("To Datetime") + "::140", _("Hours") + "::70", 
+		_("Activity Type") + "::120", _("Task") + ":Link/Task:150",
 		_("Project") + ":Link/Project:120", _("Status") + "::70"]
 		
 	conditions = "ts.docstatus = 1"
@@ -27,7 +28,8 @@
 	return columns, data
 
 def get_data(conditions, filters):
-	time_sheet = frappe.db.sql(""" select ts.name, ts.employee, tsd.from_time, tsd.to_time, tsd.hours,
+	time_sheet = frappe.db.sql(""" select ts.name, ts.employee, ts.employee_name, 
+		tsd.from_time, tsd.to_time, tsd.hours,
 		tsd.activity_type, tsd.task, tsd.project, ts.status from `tabTimesheet Detail` tsd, 
 		`tabTimesheet` ts where ts.name = tsd.parent and %s order by ts.name"""%(conditions), filters, as_list=1)
 
diff --git a/erpnext/startup/notifications.py b/erpnext/startup/notifications.py
index 991114d..58a2c79 100644
--- a/erpnext/startup/notifications.py
+++ b/erpnext/startup/notifications.py
@@ -22,12 +22,21 @@
 				"docstatus": ("<", 2)
 			},
 			"Journal Entry": {"docstatus": 0},
-			"Sales Invoice": { "outstanding_amount": (">", 0), "docstatus": ("<", 2) },
-			"Purchase Invoice": {"docstatus": 0},
+			"Sales Invoice": {
+				"outstanding_amount": (">", 0), 
+				"docstatus": ("<", 2) 
+			},
+			"Purchase Invoice": {
+				"outstanding_amount": (">", 0), 
+				"docstatus": ("<", 2)
+			},
 			"Leave Application": {"status": "Open"},
 			"Expense Claim": {"approval_status": "Draft"},
 			"Job Applicant": {"status": "Open"},
-			"Delivery Note": {"docstatus": 0},
+			"Delivery Note": {
+				"status": ("not in", ("Completed", "Closed")),
+				"docstatus": ("<", 2)
+			},
 			"Stock Entry": {"docstatus": 0},
 			"Material Request": {
 				"docstatus": ("<", 2),
@@ -40,7 +49,10 @@
 				"status": ("not in", ("Completed", "Closed")),
 				"docstatus": ("<", 2)
 			},
-			"Purchase Receipt": {"docstatus": 0},
+			"Purchase Receipt": {
+				"status": ("not in", ("Completed", "Closed")),
+				"docstatus": ("<", 2)
+			},
 			"Production Order": { "status": ("in", ("Draft", "Not Started", "In Process")) },
 			"BOM": {"docstatus": 0},
 			"Timesheet": {"status": "Draft"}