patch to fix existing holiday lists
diff --git a/patches/january_2013/holiday_list_patch.py b/patches/january_2013/holiday_list_patch.py
new file mode 100644
index 0000000..e8e8f8c
--- /dev/null
+++ b/patches/january_2013/holiday_list_patch.py
@@ -0,0 +1,41 @@
+import webnotes
+def execute():
+	for name in webnotes.conn.sql("""select name from `tabHoliday List`"""):
+		holiday_list_wrapper = webnotes.model_wrapper("Holiday List", name[0])
+		
+		desc_count = _count([d.description for d in 
+			holiday_list_wrapper.doclist.get({"doctype": "Holiday"})])
+			
+		holiday_list_obj = webnotes.get_obj(doc=holiday_list_wrapper.doc,
+			doclist=holiday_list_wrapper.doclist)
+			
+		save = False
+		
+		for desc in desc_count.keys():
+			if desc in ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
+					"Friday", "Saturday"] and desc_count[desc] > 50:
+				holiday_list_obj.doclist = holiday_list_obj.doclist.get(
+					{"description": ["!=", desc]})
+				
+				webnotes.conn.sql("""delete from `tabHoliday`
+					where parent=%s and parenttype='Holiday List' 
+					and `description`=%s""", (holiday_list_obj.doc.name, desc))
+				holiday_list_obj.doc.weekly_off = desc
+				holiday_list_obj.get_weekly_off_dates()
+				save = True
+		
+		if save:
+			holiday_list_wrapper.set_doclist(holiday_list_obj.doclist)
+			holiday_list_wrapper.save()
+				
+def _count(lst):
+	out = {}	
+	for l in lst:
+		out[l] = out.setdefault(l, 0) + 1
+		
+	return out
+		
+		
+		
+		
+		
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 2dd37ec..f9bb97c 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -578,4 +578,8 @@
 		'patch_module': 'patches.january_2013',
 		'patch_file': 'remove_support_search_criteria',
 	},
+	{
+		'patch_module': 'patches.january_2013',
+		'patch_file': 'holiday_list_patch',
+	},
 ]
\ No newline at end of file