Merge pull request #14467 from rohitwaghchaure/update_location_in_serial_no

Code cleanup and fixes for the asset
diff --git a/.travis.yml b/.travis.yml
index 4cfde8a..9bca427 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -44,11 +44,11 @@
     - stage: test
       script:
         - set -e
-        - bench run-tests
+        - bench run-tests --app erpnext
       env: Server Side Test
     - # stage
       script:
         - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz
         - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis
         - bench migrate
-      env: Patch Testing
\ No newline at end of file
+      env: Patch Testing
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index 1532e85..db46856 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -369,7 +369,7 @@
 		employee = get_employee()
 		leave_type = 'Test Earned Leave Type'
 		if not frappe.db.exists('Leave Type', leave_type):
-			leave_type = frappe.get_doc(dict(
+			leave_type_doc = frappe.get_doc(dict(
 				leave_type_name = leave_type,
 				doctype = 'Leave Type',
 				is_earned_leave = 1,
@@ -448,4 +448,4 @@
 		"docstatus": 1
 	}).insert()
 
-	allocate_leave.submit()
\ No newline at end of file
+	allocate_leave.submit()
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 24ecf26..dc2446b 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -447,7 +447,7 @@
 		else:
 			self.set_status()
 			self.update_status(self.name)
-			if(frappe.db.get_single_value("HR Settings", "email_salary_slip_to_employee")) and not frappe.flags.via_payroll_entry:
+			if (frappe.db.get_single_value("HR Settings", "email_salary_slip_to_employee")) and not frappe.flags.via_payroll_entry:
 				self.email_salary_slip()
 
 	def on_cancel(self):
@@ -466,7 +466,10 @@
 				"reference_doctype": self.doctype,
 				"reference_name": self.name
 				}
-			enqueue(method=frappe.sendmail, queue='short', timeout=300, async=True, **email_args)
+			if not frappe.flags.in_test:
+				enqueue(method=frappe.sendmail, queue='short', timeout=300, async=True, **email_args)
+			else:
+				frappe.sendmail(**email_args)
 		else:
 			msgprint(_("{0}: Employee email not found, hence email not sent").format(self.employee_name))
 
diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
index b10df8b..95be748 100644
--- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
@@ -279,7 +279,7 @@
 			"payroll_frequency": payroll_frequency,
 			"payment_account": get_random("Account")
 		}).insert()
-		create_salary_structure_assignment(employee, salary_structure)
+		create_salary_structure_assignment(employee, salary_structure.name)
 
 	elif not frappe.db.get_value("Salary Structure Assignment",{'salary_structure':sal_struct, 'employee':employee},'name'):
 		create_salary_structure_assignment(employee, sal_struct)
diff --git a/erpnext/patches/v11_0/update_total_qty_field.py b/erpnext/patches/v11_0/update_total_qty_field.py
index 6f78d8a..c5d27d2 100644
--- a/erpnext/patches/v11_0/update_total_qty_field.py
+++ b/erpnext/patches/v11_0/update_total_qty_field.py
@@ -28,7 +28,8 @@
 				when dt.name = '{0}' then {1}
 			""".format(frappe.db.escape(d.get("parent")), d.get("qty")))
 
-		frappe.db.sql('''
-			UPDATE
-				`tab%s` dt SET dt.total_qty = CASE %s END
-		''' % (doctype, " ".join(when_then)))
\ No newline at end of file
+		if when_then:
+			frappe.db.sql('''
+				UPDATE
+					`tab%s` dt SET dt.total_qty = CASE %s END
+			''' % (doctype, " ".join(when_then)))
\ No newline at end of file