Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/patches/february_2013/p09_timesheets.py b/patches/february_2013/p09_timesheets.py
index b61566f..9a9d420 100644
--- a/patches/february_2013/p09_timesheets.py
+++ b/patches/february_2013/p09_timesheets.py
@@ -5,7 +5,12 @@
 	for name in webnotes.conn.sql_list("""select name from tabTimesheet"""):
 		ts = webnotes.bean("Timesheet", name)
 		for tsd in ts.doclist.get({"doctype":"Timesheet Detail"}):
-			tl = webnotes.bean({
+			if not webnotes.conn.exists("Project", tsd.project_name):
+				tsd.project_name = None
+			if not webnotes.conn.exists("Task", tsd.task_id):
+				tsd.task_id = None
+				
+			tl = webnotes.doc({
 				"doctype": "Time Log",
 				"status": "Draft",
 				"from_time": ts.doc.timesheet_date + " " + tsd.act_start_time,
diff --git a/patches/patch_list.py b/patches/patch_list.py
index d1110da..2bd4ad8 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -200,8 +200,8 @@
 	'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Modern") # 2013-02-26',
 	'execute:webnotes.reload_doc("accounts", "Print Format", "Sales Invoice Spartan") # 2013-02-26',
 	"execute:(not webnotes.conn.exists('Role', 'Projects Manager')) and webnotes.doc({'doctype':'Role', 'role_name':'Projects Manager'}).insert()",
-	"execute:(not webnotes.conn.exists('UOM', 'Hour')) and webnotes.doc({'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Hour'}).insert()",
 	"patches.february_2013.p09_remove_cancelled_warehouses",
 	"patches.march_2013.update_po_prevdoc_doctype",
 	"patches.february_2013.p09_timesheets",
+	"execute:(not webnotes.conn.exists('UOM', 'Hour')) and webnotes.doc({'uom_name': 'Hour', 'doctype': 'UOM', 'name': 'Hour'}).insert()",
 ]
\ No newline at end of file