Fix daily_work_summary_settings migration patch
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 4a67eb4..e5cee2e 100755
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -495,7 +495,7 @@
 erpnext.patches.v10_0.update_translatable_fields
 erpnext.patches.v10_0.rename_offer_letter_to_job_offer
 execute:frappe.delete_doc('DocType', 'Production Planning Tool', ignore_missing=True)
-erpnext.patches.v10_0.migrate_daily_work_summary_settings_to_daily_work_summary_group
+erpnext.patches.v10_0.migrate_daily_work_summary_settings_to_daily_work_summary_group # 24-12-2018
 erpnext.patches.v10_0.add_default_cash_flow_mappers
 erpnext.patches.v11_0.make_quality_inspection_template
 erpnext.patches.v10_0.update_status_for_multiple_source_in_po
diff --git a/erpnext/patches/v10_0/migrate_daily_work_summary_settings_to_daily_work_summary_group.py b/erpnext/patches/v10_0/migrate_daily_work_summary_settings_to_daily_work_summary_group.py
index 3d15bbc..102b6da 100644
--- a/erpnext/patches/v10_0/migrate_daily_work_summary_settings_to_daily_work_summary_group.py
+++ b/erpnext/patches/v10_0/migrate_daily_work_summary_settings_to_daily_work_summary_group.py
@@ -6,37 +6,36 @@
 
 
 def execute():
-	frappe.reload_doc("hr", "doctype", "daily_work_summary_group")
-	frappe.reload_doc("hr", "doctype", "daily_work_summary_group_user")
+	if not frappe.db.table_exists('Daily Work Summary Group'):
+		frappe.reload_doc("hr", "doctype", "daily_work_summary_group")
+		frappe.reload_doc("hr", "doctype", "daily_work_summary_group_user")
 
-	# check if Daily Work Summary Settings Company table exists
-	try:
-		frappe.db.sql('DESC `tabDaily Work Summary Settings Company`')
-	except Exception:
-		return
+		# check if Daily Work Summary Settings Company table exists
+		try:
+			frappe.db.sql('DESC `tabDaily Work Summary Settings Company`')
+		except Exception:
+			return
 
-	# get the previously saved settings
-	previous_setting = get_previous_setting()
-	if previous_setting["companies"]:
-		for d in previous_setting["companies"]:
-			users = frappe.get_list("Employee", dict(
-				company=d.company, user_id=("!=", " ")), "user_id as user")
-			if(len(users)):
-				# create new group entry for each company entry
-				new_group = frappe.get_doc(dict(doctype="Daily Work Summary Group",
-					name="Daily Work Summary for " + d.company,
-					users=users,
-					send_emails_at=d.send_emails_at,
-					subject=previous_setting["subject"],
-					message=previous_setting["message"]))
-				new_group.flags.ignore_permissions = True
-				new_group.flags.ignore_validate = True
-				new_group.insert(ignore_if_duplicate = True)
-	frappe.delete_doc("Daily Work Summary Settings")
-	frappe.delete_doc("Daily Work Summary Settings Company")
+		# get the previously saved settings
+		previous_setting = get_previous_setting()
+		if previous_setting["companies"]:
+			for d in previous_setting["companies"]:
+				users = frappe.get_list("Employee", dict(
+					company=d.company, user_id=("!=", " ")), "user_id as user")
+				if(len(users)):
+					# create new group entry for each company entry
+					new_group = frappe.get_doc(dict(doctype="Daily Work Summary Group",
+						name="Daily Work Summary for " + d.company,
+						users=users,
+						send_emails_at=d.send_emails_at,
+						subject=previous_setting["subject"],
+						message=previous_setting["message"]))
+					new_group.flags.ignore_permissions = True
+					new_group.flags.ignore_validate = True
+					new_group.insert(ignore_if_duplicate = True)
 
-def get_setting_companies():
-	return frappe.db.sql("select * from `tabDaily Work Summary Settings Company`", as_dict=True)
+	frappe.delete_doc("DocType", "Daily Work Summary Settings")
+	frappe.delete_doc("DocType", "Daily Work Summary Settings Company")
 
 
 def get_previous_setting():
@@ -47,3 +46,6 @@
 		obj[field] = value
 	obj["companies"] = get_setting_companies()
 	return obj
+
+def get_setting_companies():
+	return frappe.db.sql("select * from `tabDaily Work Summary Settings Company`", as_dict=True)
\ No newline at end of file