Merge branch 'master' into production

Conflicts:
	patches/patch_list.py
	production/doctype/bom_explosion_item/bom_explosion_item.txt
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt
index 3b27049..db2abfa 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.txt
+++ b/buying/doctype/supplier_quotation/supplier_quotation.txt
@@ -4,7 +4,7 @@
   "docstatus": 0, 
   "creation": "2012-08-06 11:15:46", 
   "modified_by": "Administrator", 
-  "modified": "2012-08-02 18:04:35"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "is_submittable": 1, 
@@ -697,7 +697,7 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "cancel": 1, 
   "permlevel": 0
  }, 
diff --git a/home/doctype/home_control/home_control.py b/home/doctype/home_control/home_control.py
index 75ab222..3b7ae32 100644
--- a/home/doctype/home_control/home_control.py
+++ b/home/doctype/home_control/home_control.py
@@ -265,7 +265,7 @@
 	# module settings
 	# -------------------------------------------------------------------------------------------------------
 	def get_module_order(self):
-		show_list = ['Home','Setup','Accounts','Selling','Buying','Support','Stock','HR','Projects','Analysis','Production']
+		show_list = ['Home','Setup','Accounts','Selling','Buying','Support','Stock','HR','Projects','Analysis','Manufacturing']
 		ml = filter(lambda x: x[0] in show_list, \
 			sql("select name, module_label, module_seq, is_hidden from `tabModule Def` where docstatus<2 order by module_seq asc, module_label asc"))
 		return webnotes.conn.convert_to_lists(ml)
diff --git a/home/page/desktop/desktop.css b/home/page/desktop/desktop.css
index f1c4fb0..88a437c 100644
--- a/home/page/desktop/desktop.css
+++ b/home/page/desktop/desktop.css
@@ -6,7 +6,7 @@
 .sprite-hr{ background-position: 0 -439px; width: 40px; height: 32px; } 
 .sprite-kb{ background-position: 0 -521px; width: 24px; height: 39px; } 
 .sprite-messages{ background-position: 0 -610px; width: 40px; height: 26px; } 
-.sprite-production{ background-position: 0 -686px; width: 40px; height: 33px; } 
+.sprite-manufacturing{ background-position: 0 -686px; width: 40px; height: 33px; } 
 .sprite-project{ background-position: 0 -769px; width: 40px; height: 22px; } 
 .sprite-report{ background-position: 0 -841px; width: 29px; height: 40px; } 
 .sprite-selling{ background-position: 0 -931px; width: 34px; height: 40px; } 
@@ -26,7 +26,7 @@
 .sprite-support{ margin-top: 8px; margin-left: 8px; } 
 .sprite-hr{ margin-top: 12px; margin-left: 8px; } 
 .sprite-project{ margin-top: 16px; margin-left: 8px; } 
-.sprite-production{ margin-top: 10px; margin-left: 8px; } 
+.sprite-manufacturing{ margin-top: 10px; margin-left: 8px; } 
 .sprite-website{ margin-top: 8px; margin-left: 8px; } 
 .sprite-setting{ margin-top: 8px; margin-left: 8px; } 
 .sprite-report{ margin-top: 8px; margin-left: 14px; } 
diff --git a/home/page/desktop/desktop.js b/home/page/desktop/desktop.js
index 75f2922..f9a3b54 100644
--- a/home/page/desktop/desktop.js
+++ b/home/page/desktop/desktop.js
@@ -33,7 +33,7 @@
 		'Support': { sprite: 'support', label: 'Support'},
 		'HR': { sprite: 'hr', label: 'Human<br />Resources'},
 		'Projects':	{ sprite: 'project', label: 'Projects'},
-		'Production': { sprite: 'production', label: 'Production'},
+		'Manufacturing': { sprite: 'manufacturing', label: 'Manufacturing'},
 		'Website': { sprite: 'website', label: 'Website'},
 		'Activity': { sprite: 'feed', label: 'Activity'},
 		'Setup': { sprite: 'setting', label: 'Setup'},
diff --git a/manufacturing/__init__.py b/manufacturing/__init__.py
new file mode 100644
index 0000000..07594ad
--- /dev/null
+++ b/manufacturing/__init__.py
@@ -0,0 +1,5 @@
+from __future__ import unicode_literals
+install_docs = [
+	{"doctype":"Role", "role_name":"Manufacturing Manager", "name":"Manufacturing Manager"},
+	{"doctype":"Role", "role_name":"Manufacturing User", "name":"Manufacturing User"},
+]
diff --git a/production/doctype/__init__.py b/manufacturing/doctype/__init__.py
similarity index 100%
rename from production/doctype/__init__.py
rename to manufacturing/doctype/__init__.py
diff --git a/production/doctype/bom/__init__.py b/manufacturing/doctype/bom/__init__.py
similarity index 100%
rename from production/doctype/bom/__init__.py
rename to manufacturing/doctype/bom/__init__.py
diff --git a/production/doctype/bom/bom.js b/manufacturing/doctype/bom/bom.js
similarity index 75%
rename from production/doctype/bom/bom.js
rename to manufacturing/doctype/bom/bom.js
index 9dffd6c..9d0175f 100644
--- a/production/doctype/bom/bom.js
+++ b/manufacturing/doctype/bom/bom.js
@@ -17,11 +17,11 @@
 // On REFRESH
 cur_frm.cscript.refresh = function(doc,dt,dn){
 	cur_frm.toggle_enable("item", doc.__islocal);
+	if (!doc.__islocal && doc.docstatus==0) {
+		cur_frm.set_intro("Submit the BOM to use it in production");
+	}
 }
 
-
-// Triggers
-//--------------------------------------------------------------------------------------------------
 cur_frm.cscript.item = function(doc, dt, dn) {
 	if (doc.item) {
 		get_server_fields('get_item_detail',doc.item,'',doc,dt,dn,1);
@@ -36,7 +36,8 @@
 			calculate_op_cost(doc, dt, dn);
 			calculate_total(doc);
 		}
-		get_server_fields('get_workstation_details',d.workstation,'bom_operations',doc,dt,dn,1, callback);
+		get_server_fields('get_workstation_details', d.workstation, 
+			'bom_operations', doc, dt, dn, 1, callback);
 	}
 }
 
@@ -49,12 +50,10 @@
 
 cur_frm.cscript.time_in_mins = cur_frm.cscript.hour_rate;
 
-
 cur_frm.cscript.item_code = function(doc, cdt, cdn) {
 	get_bom_material_detail(doc, cdt, cdn);
 }
 
-
 cur_frm.cscript.bom_no	= function(doc, cdt, cdn) {
 	get_bom_material_detail(doc, cdt, cdn);
 }
@@ -89,9 +88,16 @@
 	calculate_total(doc);
 }
 
-
-cur_frm.cscript.rate = cur_frm.cscript.qty;
-
+cur_frm.cscript.rate = function(doc, cdt, cdn) {
+	var d = locals[cdt][cdn];
+	if (d.bom_no) {
+		msgprint("You can not change rate if BOM mentioned agianst any item");
+		get_bom_material_detail(doc, cdt, cdn);
+	} else {
+		calculate_rm_cost(doc, cdt, cdn);
+		calculate_total(doc);
+	}
+}
 
 cur_frm.cscript.is_default = function(doc, cdt, cdn) {
 	if (doc.docstatus == 1)
@@ -104,13 +110,11 @@
 		$c_obj(make_doclist(dt, dn), 'manage_active_bom', '', '');
 }
 
-
-// Calculate Operating Cost
 var calculate_op_cost = function(doc, dt, dn) {	
 	var op = getchildren('BOM Operation', doc.name, 'bom_operations');
 	total_op_cost = 0;
 	for(var i=0;i<op.length;i++) {
-		op_cost =	flt(op[i].hour_rate) * flt(op[i].time_in_mins) / 60;
+		op_cost =	flt(flt(op[i].hour_rate) * flt(op[i].time_in_mins) / 60, 2);
 		set_multiple('BOM Operation',op[i].name, {'operating_cost': op_cost}, 'bom_operations');
 		total_op_cost += op_cost;
 	}
@@ -118,15 +122,14 @@
 	refresh_field('operating_cost');
 }
 
-
-// Calculate Raw Material Cost
 var calculate_rm_cost = function(doc, dt, dn) {	
 	var rm = getchildren('BOM Item', doc.name, 'bom_materials');
 	total_rm_cost = 0;
 	for(var i=0;i<rm.length;i++) {
 		amt =	flt(rm[i].rate) * flt(rm[i].qty);
 		set_multiple('BOM Item',rm[i].name, {'amount': amt}, 'bom_materials');
-		set_multiple('BOM Item',rm[i].name, {'qty_consumed_per_unit': flt(rm[i].qty)/flt(doc.quantity)}, 'bom_materials');
+		set_multiple('BOM Item',rm[i].name, 
+			{'qty_consumed_per_unit': flt(rm[i].qty)/flt(doc.quantity)}, 'bom_materials');
 		total_rm_cost += amt;
 	}
 	doc.raw_material_cost = total_rm_cost;
@@ -142,7 +145,10 @@
 
 
 cur_frm.fields_dict['item'].get_query = function(doc) {
-	return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` WHERE is_manufactured_item = "Yes" and (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.`%(key)s` like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
+	return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` \
+		WHERE is_manufactured_item = "Yes" and (IFNULL(`tabItem`.`end_of_life`,"") = "" OR \
+		 	`tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND \
+		 	`tabItem`.`%(key)s` like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
 }
 
 cur_frm.fields_dict['project_name'].get_query = function(doc, dt, dn) {
@@ -152,12 +158,18 @@
 }
 
 cur_frm.fields_dict['bom_materials'].grid.get_field('item_code').get_query = function(doc) {
-	return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.`%(key)s` like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
+	return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` \
+		WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" \
+			OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.`%(key)s` like "%s" \
+		ORDER BY `tabItem`.`name` LIMIT 50';
 }
 
 cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = function(doc) {
 	var d = locals[this.doctype][this.docname];
-	return 'SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
+	return 'SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` \
+		WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND \
+		 	`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \
+		ORDER BY `tabBOM`.`name` LIMIT 50';
 }
 
 cur_frm.cscript.validate = function(doc, dt, dn) {
diff --git a/production/doctype/bom/bom.py b/manufacturing/doctype/bom/bom.py
similarity index 71%
rename from production/doctype/bom/bom.py
rename to manufacturing/doctype/bom/bom.py
index ac21d21..857458e 100644
--- a/production/doctype/bom/bom.py
+++ b/manufacturing/doctype/bom/bom.py
@@ -64,22 +64,20 @@
 	def get_workstation_details(self,workstation):
 		""" Fetch hour rate from workstation master"""
 
-		ws = sql("select hour_rate from `tabWorkstation` where name = %s",workstation , as_dict = 1)
-		ret = {
-			'hour_rate'				: ws and flt(ws[0]['hour_rate']) or '',
-		}
-		return ret
-
+		ws = sql("select hour_rate from `tabWorkstation` where name = %s", 
+			workstation , as_dict = 1)
+		return {'hour_rate'	: ws and flt(ws[0]['hour_rate']) or ''}
 
 
 	def validate_rm_item(self, item):
 		""" Validate raw material items"""
 
 		if item[0]['name'] == self.doc.item:
-			msgprint(" Item_code: "+item[0]['name']+" in materials tab cannot be same as FG Item in BOM := " +cstr(self.doc.name), raise_exception=1)
+			msgprint("Item_code: %s in materials tab cannot be same as FG Item", 
+				item[0]['name'], raise_exception=1)
 		
 		if item and item[0]['is_asset_item'] == 'Yes':
-			msgprint("Sorry!!! Item " + item[0]['name'] + " is an Asset of the company. Entered in BOM => " + cstr(self.doc.name), raise_exception = 1)
+			msgprint("Item: %s is an asset item, please check", item[0]['name'], raise_exception=1)
 
 		if not item or item[0]['docstatus'] == 2:
 			msgprint("Item %s does not exist in system" % item[0]['item_code'], raise_exception = 1)
@@ -113,9 +111,7 @@
 		"""	Get raw material rate as per selected method, if bom exists takes bom cost """
 
 		if arg['bom_no']:
-			bom = sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
-				where is_active = 'Yes' and name = %s""", arg['bom_no'], as_dict=1)
-			rate = bom and bom[0]['unit_cost'] or 0
+			rate = self.get_bom_unitcost(arg['bom_no'])
 		elif arg and (arg['is_purchase_item'] == 'Yes' or arg['is_sub_contracted_item'] == 'Yes'):
 			if self.doc.rm_cost_as_per == 'Valuation Rate':
 				rate = self.get_valuation_rate(arg)
@@ -126,7 +122,10 @@
 
 		return rate
 
-	
+	def get_bom_unitcost(self, bom_no):
+		bom = sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
+			where is_active = 'Yes' and name = %s""", bom_no, as_dict=1)
+		return bom and bom[0]['unit_cost'] or 0
 
 	def get_valuation_rate(self, arg):
 		""" Get average valuation rate of relevant warehouses 
@@ -139,7 +138,8 @@
 		warehouse = sql("select warehouse from `tabBin` where item_code = %s", arg['item_code'])
 		rate = []
 		for wh in warehouse:
-			r = get_obj('Valuation Control').get_incoming_rate(dt, time, arg['item_code'], wh[0], qty = arg.get('qty', 0))
+			r = get_obj('Valuation Control').get_incoming_rate(dt, time, 
+				arg['item_code'], wh[0], qty=arg.get('qty', 0))
 			if r:
 				rate.append(r)
 
@@ -148,15 +148,20 @@
 
 
 	def manage_default_bom(self):
-		""" Uncheck others if current one is selected as default, update default bom in item master"""
+		""" Uncheck others if current one is selected as default, 
+			update default bom in item master
+		"""
 
 		if self.doc.is_default and self.doc.is_active == 'Yes':
-			sql("update `tabBOM` set is_default = 0 where name != %s and item=%s", (self.doc.name, self.doc.item))
+			sql("update `tabBOM` set is_default = 0 where name != %s and item=%s", 
+				(self.doc.name, self.doc.item))
 
 			# update default bom in Item Master
-			sql("update `tabItem` set default_bom = %s where name = %s", (self.doc.name, self.doc.item))
+			sql("update `tabItem` set default_bom = %s where name = %s", 
+				(self.doc.name, self.doc.item))
 		else:
-			sql("update `tabItem` set default_bom = '' where name = %s and default_bom = %s", (self.doc.item, self.doc.name))
+			sql("update `tabItem` set default_bom = '' where name = %s and default_bom = %s", 
+			 	(self.doc.item, self.doc.name))
 
 
 	def manage_active_bom(self):
@@ -181,39 +186,33 @@
 
 	def calculate_cost(self):
 		"""Calculate bom totals"""
-		self.doc.costing_date = nowdate()
 		self.calculate_op_cost()
 		self.calculate_rm_cost()
 		self.doc.total_cost = self.doc.raw_material_cost + self.doc.operating_cost
 		self.doc.modified = now()
 		self.doc.save()
-
-		self.update_flat_bom_engine(is_submit = self.doc.docstatus)
-
 	
 
 	def calculate_op_cost(self):
 		"""Update workstation rate and calculates totals"""
 		total_op_cost = 0
 		for d in getlist(self.doclist, 'bom_operations'):
-			hour_rate = sql("select hour_rate from `tabWorkstation` where name = %s", cstr(d.workstation))
-			d.hour_rate = hour_rate and flt(hour_rate[0][0]) or d.hour_rate or 0
-			d.operating_cost = d.hour_rate and d.time_in_mins and \
-				flt(d.hour_rate) * flt(d.time_in_mins) / 60 or d.operating_cost
+			if d.hour_rate and d.time_in_mins:
+				d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60.0
 			d.save()
-			total_op_cost += d.operating_cost
+			total_op_cost += flt(d.operating_cost)
 		self.doc.operating_cost = total_op_cost
+		
 
 
 	def calculate_rm_cost(self):
 		"""Fetch RM rate as per today's valuation rate and calculate totals"""
 		total_rm_cost = 0
 		for d in getlist(self.doclist, 'bom_materials'):
-			arg = {'item_code': d.item_code, 'qty': d.qty, 'bom_no': d.bom_no}
-			ret = self.get_bom_material_detail(cstr(arg))
-			for k in ret:
-				d.fields[k] = ret[k]
+			if d.bom_no:
+				d.rate = self.get_bom_unitcost(d.bom_no)
 			d.amount = flt(d.rate) * flt(d.qty)
+			d.qty_consumed_per_unit = flt(d.qty) / flt(self.doc.quantity)
 			d.save()
 			total_rm_cost += d.amount
 		self.doc.raw_material_cost = total_rm_cost
@@ -224,20 +223,22 @@
 		""" Validate main FG item"""
 		item = self.get_item_det(self.doc.item)
 		if not item:
-			msgprint("Item %s does not exists in the system or expired." % self.doc.item, raise_exception = 1)
+			msgprint("Item %s does not exists in the system or expired." % 
+				self.doc.item, raise_exception = 1)
 
-		elif item[0]['is_manufactured_item'] != 'Yes' and item[0]['is_sub_contracted_item'] != 'Yes':
-			msgprint("""As Item: %s is not a manufactured / sub-contracted item, 
+		elif item[0]['is_manufactured_item'] != 'Yes' \
+				and item[0]['is_sub_contracted_item'] != 'Yes':
+			msgprint("""As Item: %s is not a manufactured / sub-contracted item, \
 				you can not make BOM for it""" % self.doc.item, raise_exception = 1)
 
 
-
 	def validate_operations(self):
 		""" Check duplicate operation no"""
 		self.op = []
 		for d in getlist(self.doclist, 'bom_operations'):
 			if cstr(d.operation_no) in self.op:
-				msgprint("Operation no: %s is repeated in Operations Table"% d.operation_no, raise_exception=1)
+				msgprint("Operation no: %s is repeated in Operations Table" % 
+					d.operation_no, raise_exception=1)
 			else:
 				# add operation in op list
 				self.op.append(cstr(d.operation_no))
@@ -248,40 +249,47 @@
 		for m in getlist(self.doclist, 'bom_materials'):
 			# check if operation no not in op table
 			if cstr(m.operation_no) not in self.op:
-				msgprint("""Operation no: %s against item: %s at row no: %s is not present 
-					at Operations table"""% (m.operation_no, m.item_code, m.idx), raise_exception = 1)
+				msgprint("""Operation no: %s against item: %s at row no: %s \
+					is not present at Operations table""" % 
+					(m.operation_no, m.item_code, m.idx), raise_exception = 1)
 		
 			item = self.get_item_det(m.item_code)
-			if item[0]['is_manufactured_item'] == 'Yes' or item[0]['is_sub_contracted_item'] == 'Yes':
+			if item[0]['is_manufactured_item'] == 'Yes' or \
+					item[0]['is_sub_contracted_item'] == 'Yes':
 				if not m.bom_no:
-					msgprint("Please enter BOM No aginst item: %s at row no: %s"% (m.item_code, m.idx), raise_exception=1)
+					msgprint("Please enter BOM No aginst item: %s at row no: %s" % 
+						(m.item_code, m.idx), raise_exception=1)
 				else:
 					self.validate_bom_no(m.item_code, m.bom_no, m.idx)
 
 			elif m.bom_no:
-				msgprint("""As Item %s is not a manufactured / sub-contracted item, 
-					you can enter BOM against it (Row No: %s)."""% (m.item_code, m.idx), raise_excepiton = 1)
+				msgprint("""As Item %s is not a manufactured / sub-contracted item, \
+					you can enter BOM against it (Row No: %s).""" % 
+					(m.item_code, m.idx), raise_exception = 1)
 
 			if flt(m.qty) <= 0:
-				msgprint("Please enter qty against raw material: %s at row no: %s"% (m.item_code, m.idx), raise_exception = 1)
+				msgprint("Please enter qty against raw material: %s at row no: %s" % 
+					(m.item_code, m.idx), raise_exception = 1)
 
 			self.check_if_item_repeated(m.item_code, m.operation_no, check_list)
 
 
-
 	def validate_bom_no(self, item, bom_no, idx):
 		"""Validate BOM No of sub-contracted items"""
 		bom = sql("""select name from `tabBOM` where name = %s and item = %s 
-			and ifnull(is_active, 'No') = 'Yes'	and docstatus < 2 """, (bom_no, item), as_dict =1)
+			and ifnull(is_active, 'No') = 'Yes'	and docstatus < 2 """, 
+			(bom_no, item), as_dict =1)
 		if not bom:
 			msgprint("""Incorrect BOM No: %s against item: %s at row no: %s.
-				It may be inactive or cancelled or for some other item."""% (bom_no, item, idx), raise_exception = 1)
+				It may be inactive or cancelled or for some other item.""" % 
+				(bom_no, item, idx), raise_exception = 1)
 				
 
 
 	def check_if_item_repeated(self, item, op, check_list):
 		if [cstr(item), cstr(op)] in check_list:
-			msgprint("Item %s has been entered twice against same operation" % item, raise_exception = 1)
+			msgprint("Item %s has been entered twice against same operation" % 
+				item, raise_exception = 1)
 		else:
 			check_list.append([cstr(item), cstr(op)])
 
@@ -292,13 +300,14 @@
 		self.validate_materials()
 
 	def check_recursion(self):
-		""" Check whether reqursion occurs in any bom"""
+		""" Check whether recursion occurs in any bom"""
 
 		check_list = [['parent', 'bom_no', 'parent'], ['bom_no', 'parent', 'child']]
 		for d in check_list:
 			bom_list, count = [self.doc.name], 0
 			while (len(bom_list) > count ):
-				boms = sql(" select %s from `tabBOM Item` where %s = '%s' " % (d[0], d[1], cstr(bom_list[count])))
+				boms = sql(" select %s from `tabBOM Item` where %s = '%s' " % 
+					(d[0], d[1], cstr(bom_list[count])))
 				count = count + 1
 				for b in boms:
 					if b[0] == self.doc.name:
@@ -308,30 +317,32 @@
 						bom_list.append(b[0])
 
 
-
 	def on_update(self):
 		self.check_recursion()
+		self.update_cost_by_traversing()
+		self.update_flat_bom_by_traversing()
+		
 
 
-
-	def add_to_flat_bom_detail(self, is_submit = 0):
+	def add_to_flat_bom_detail(self):
 		"Add items to Flat BOM table"
 		self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
 		for d in self.cur_flat_bom_items:
 			ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', 1, self.doclist)
 			for i in d.keys():
 				ch.fields[i] = d[i]
-			ch.docstatus = is_submit
+			ch.docstatus = self.doc.docstatus
 			ch.save(1)
 		self.doc.save()
 
 
-
 	def get_child_flat_bom_items(self, bom_no, qty):
 		""" Add all items from Flat BOM of child BOM"""
-
-		child_fb_items = sql("""select item_code, description, stock_uom, qty, rate, amount, parent_bom, mat_detail_no, qty_consumed_per_unit 
-			from `tabBOM Explosion Item` where parent = '%s' and docstatus = 1""" % bom_no, as_dict = 1)
+		
+		child_fb_items = sql("""select item_code, description, stock_uom, qty, rate, 
+			amount, parent_bom, mat_detail_no, qty_consumed_per_unit 
+			from `tabBOM Explosion Item` where parent = '%s' and docstatus = 1""" %
+			bom_no, as_dict = 1)
 		for d in child_fb_items:
 			self.cur_flat_bom_items.append({
 				'item_code'				: d['item_code'], 
@@ -347,31 +358,30 @@
 			})
 
 
-	# Get Current Flat BOM Items
-	# -----------------------------
-	def get_current_flat_bom_items(self):
+	def get_flat_bom_items(self):
 		""" Get all raw materials including items from child bom"""
 		self.cur_flat_bom_items = []
 		for d in getlist(self.doclist, 'bom_materials'):
-			self.cur_flat_bom_items.append({
-				'item_code'				: d.item_code, 
-				'description'			: d.description, 
-				'stock_uom'				: d.stock_uom, 
-				'qty'					: flt(d.qty),
-				'rate'					: flt(d.rate), 
-				'amount'				: flt(d.amount),
-				'parent_bom'			: d.parent, #item and item[0][0]=='No' and d.bom_no or d.parent, 
-				'mat_detail_no'			: d.name,
-				'qty_consumed_per_unit' : flt(d.qty_consumed_per_unit)
-			})
 			if d.bom_no:
 				self.get_child_flat_bom_items(d.bom_no, d.qty)
+			else:
+				self.cur_flat_bom_items.append({
+					'item_code'				: d.item_code, 
+					'description'			: d.description, 
+					'stock_uom'				: d.stock_uom, 
+					'qty'					: flt(d.qty),
+					'rate'					: flt(d.rate), 
+					'amount'				: flt(d.amount),
+					'parent_bom'			: d.parent,
+					'mat_detail_no'			: d.name,
+					'qty_consumed_per_unit' : flt(d.qty_consumed_per_unit)
+				})
 
 
-	def update_flat_bom_engine(self, is_submit = 0):
+	def update_flat_bom(self):
 		""" Update Flat BOM, following will be correct data"""
-		self.get_current_flat_bom_items()
-		self.add_to_flat_bom_detail(is_submit)
+		self.get_flat_bom_items()
+		self.add_to_flat_bom_detail()
 
 
 	def get_parent_bom_list(self, bom_no):
@@ -381,17 +391,43 @@
 
 	def on_submit(self):
 		self.manage_default_bom()
-		self.update_flat_bom_engine(1)
-
 
 	def on_cancel(self):
 		# check if used in any other bom
 		par = sql("""select t1.parent from `tabBOM Item` t1, `tabBOM` t2 
-			where t1.parent = t2.name and t1.bom_no = %s and t1.docstatus = 1 and t2.is_active = 'Yes'""", self.doc.name)
+			where t1.parent = t2.name and t1.bom_no = %s and t1.docstatus = 1 
+			and t2.is_active = 'Yes'""", self.doc.name)
 		if par:
-			msgprint("BOM can not be cancelled, as it is a child item in following active BOM %s"% [d[0] for d in par])
-			raise Exception
+			msgprint("""BOM can not be cancelled, as it is a child item \
+				in following active BOM %s""" % [d[0] for d in par], raise_exception=1)
 			
 		webnotes.conn.set(self.doc, "is_active", "No")
 		webnotes.conn.set(self.doc, "is_default", 0)
 		self.manage_default_bom()
+		self.update_flat_bom_by_traversing()
+		
+	def traverse_tree(self):
+		def _get_childs(bom_no):
+			return [cstr(d[0]) for d in webnotes.conn.sql("""select bom_no from `tabBOM Item` 
+				where parent = %s and ifnull(bom_no, '') != ''""", bom_no)]
+				
+		bom_list, count = [self.doc.name], 0		
+		while(count < len(bom_list)):
+			for child_bom in _get_childs(bom_list[count]):
+				if child_bom not in bom_list:
+					bom_list.append(child_bom)
+			count += 1
+			
+		return bom_list
+		
+	def update_cost_by_traversing(self):
+		bom_list = self.traverse_tree()
+		bom_list.reverse()
+		for bom in bom_list:
+			get_obj("BOM", bom, with_children=1).calculate_cost()
+			
+	def update_flat_bom_by_traversing(self):
+		bom_list = self.traverse_tree()
+		bom_list.reverse()
+		for bom in bom_list:
+			get_obj("BOM", bom, with_children=1).update_flat_bom()
\ No newline at end of file
diff --git a/production/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt
similarity index 93%
rename from production/doctype/bom/bom.txt
rename to manufacturing/doctype/bom/bom.txt
index ed70045..a2495d5 100644
--- a/production/doctype/bom/bom.txt
+++ b/manufacturing/doctype/bom/bom.txt
@@ -4,14 +4,14 @@
   "docstatus": 0, 
   "creation": "2012-07-03 13:30:03", 
   "modified_by": "Administrator", 
-  "modified": "2012-12-03 13:29:26"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "istable": 0, 
   "in_create": 0, 
   "allow_print": 0, 
   "search_fields": "item", 
-  "module": "Production", 
+  "module": "Manufacturing", 
   "document_type": "Master", 
   "allow_attach": 0, 
   "read_only": 0, 
@@ -55,12 +55,10 @@
  {
   "description": "Select the item code for which Bill of Material is being created", 
   "oldfieldtype": "Link", 
-  "colour": "White:FFF", 
   "doctype": "DocField", 
   "label": "Item", 
   "oldfieldname": "item", 
   "permlevel": 0, 
-  "trigger": "Client", 
   "fieldname": "item", 
   "fieldtype": "Link", 
   "search_index": 1, 
@@ -71,7 +69,6 @@
  {
   "description": "Total quantity of items for which raw materials required and operations done will be defined", 
   "oldfieldtype": "Currency", 
-  "colour": "White:FFF", 
   "doctype": "DocField", 
   "label": "Quantity", 
   "oldfieldname": "quantity", 
@@ -90,7 +87,6 @@
  {
   "no_copy": 1, 
   "oldfieldtype": "Select", 
-  "colour": "White:FFF", 
   "allow_on_submit": 1, 
   "doctype": "DocField", 
   "label": "Is Active", 
@@ -103,10 +99,9 @@
   "options": "\nYes\nNo"
  }, 
  {
-  "allow_on_submit": 1, 
   "no_copy": 1, 
   "oldfieldtype": "Check", 
-  "colour": "White:FFF", 
+  "allow_on_submit": 1, 
   "doctype": "DocField", 
   "label": "Is Default", 
   "oldfieldname": "is_default", 
@@ -125,7 +120,6 @@
  {
   "description": "Specify the operations, operating cost and give a unique Operation no to your operations.", 
   "oldfieldtype": "Table", 
-  "colour": "White:FFF", 
   "doctype": "DocField", 
   "label": "BOM Operations", 
   "oldfieldname": "bom_operations", 
@@ -153,7 +147,6 @@
  {
   "description": "Enter the raw materials required to manufacture the BOM item. Specify the operation no as entered in the previous tab which will be performed on the raw materials entered.", 
   "oldfieldtype": "Table", 
-  "colour": "White:FFF", 
   "doctype": "DocField", 
   "label": "BOM Item", 
   "oldfieldname": "bom_materials", 
@@ -186,6 +179,12 @@
  }, 
  {
   "doctype": "DocField", 
+  "fieldname": "col_break24", 
+  "fieldtype": "Column Break", 
+  "permlevel": 0
+ }, 
+ {
+  "doctype": "DocField", 
   "label": "Total Cost", 
   "fieldname": "total_cost", 
   "fieldtype": "Float", 
@@ -201,13 +200,12 @@
  {
   "description": "Select name of the project if BOM need to be created against any project", 
   "oldfieldtype": "Link", 
+  "doctype": "DocField", 
   "label": "Project Name", 
   "oldfieldname": "project_name", 
-  "trigger": "Client", 
+  "options": "Project", 
   "fieldname": "project_name", 
   "fieldtype": "Link", 
-  "doctype": "DocField", 
-  "options": "Project", 
   "permlevel": 0, 
   "in_filter": 1
  }, 
@@ -224,7 +222,6 @@
   "doctype": "DocField", 
   "label": "Item Description", 
   "oldfieldname": "description", 
-  "width": "300px", 
   "fieldname": "description", 
   "fieldtype": "Small Text", 
   "permlevel": 0
@@ -268,7 +265,6 @@
  {
   "no_copy": 1, 
   "oldfieldtype": "Text", 
-  "colour": "White:FFF", 
   "doctype": "DocField", 
   "label": "Remarks", 
   "oldfieldname": "remarks", 
@@ -291,7 +287,6 @@
   "permlevel": 1, 
   "no_copy": 1, 
   "oldfieldtype": "Table", 
-  "colour": "White:FFF", 
   "doctype": "DocField", 
   "label": "BOM Explosion Item", 
   "oldfieldname": "flat_bom_details", 
@@ -320,13 +315,13 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "cancel": 1, 
   "permlevel": 0
  }, 
  {
   "doctype": "DocPerm", 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "permlevel": 1
  }, 
  {
@@ -334,13 +329,13 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "cancel": 1, 
   "permlevel": 0
  }, 
  {
   "doctype": "DocPerm", 
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "permlevel": 1
  }
 ]
\ No newline at end of file
diff --git a/production/doctype/bom/bom_list.js b/manufacturing/doctype/bom/bom_list.js
similarity index 100%
rename from production/doctype/bom/bom_list.js
rename to manufacturing/doctype/bom/bom_list.js
diff --git a/manufacturing/doctype/bom/test_bom.py b/manufacturing/doctype/bom/test_bom.py
new file mode 100644
index 0000000..68d9ce8
--- /dev/null
+++ b/manufacturing/doctype/bom/test_bom.py
@@ -0,0 +1,147 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+from __future__ import unicode_literals
+import unittest
+import webnotes
+import webnotes.model
+from webnotes.utils import nowdate, flt
+from accounts.utils import get_fiscal_year
+from webnotes.model.doclist import DocList
+import copy
+
+company = webnotes.conn.get_default("company")
+
+
+def load_data():
+	
+	# create default warehouse
+	if not webnotes.conn.exists("Warehouse", "Default Warehouse"):
+		webnotes.insert({"doctype": "Warehouse", 
+			"warehouse_name": "Default Warehouse",
+			"warehouse_type": "Stores"})
+			
+	# create UOM: Nos.
+	if not webnotes.conn.exists("UOM", "Nos"):
+		webnotes.insert({"doctype": "UOM", "uom_name": "Nos"})
+	
+	from webnotes.tests import insert_test_data
+	# create item groups and items
+	insert_test_data("Item Group", 
+		sort_fn=lambda ig: (ig[0].get('parent_item_group'), ig[0].get('name')))
+	insert_test_data("Item")
+
+base_bom_fg = [
+	{"doctype": "BOM", "item": "Android Jack D", "quantity": 1,
+		"is_active": "Yes", "is_default": 1, "uom": "Nos"},
+	{"doctype": "BOM Operation", "operation_no": 1, "parentfield": "bom_operations",
+		"opn_description": "Development", "hour_rate": 10, "time_in_mins": 90}, 
+	{"doctype": "BOM Item", "item_code": "Home Desktop 300", "operation_no": 1, 
+		"qty": 2, "rate": 20, "stock_uom": "Nos", "parentfield": "bom_materials"},
+	{"doctype": "BOM Item", "item_code": "Home Desktop 100", "operation_no": 1, 
+		"qty": 1, "rate": 300, "stock_uom": "Nos", "parentfield": "bom_materials"},
+	{"doctype": "BOM Item", "item_code": "Nebula 7", "operation_no": 1, 
+			"qty": 5, "stock_uom": "Nos", "parentfield": "bom_materials"},
+]
+
+base_bom_child = [
+	{"doctype": "BOM", "item": "Nebula 7", "quantity": 5,
+		"is_active": "Yes", "is_default": 1, "uom": "Nos"},
+	{"doctype": "BOM Operation", "operation_no": 1, "parentfield": "bom_operations",
+		"opn_description": "Development"}, 
+	{"doctype": "BOM Item", "item_code": "Android Jack S", "operation_no": 1, 
+		"qty": 10, "stock_uom": "Nos", "parentfield": "bom_materials"}
+]
+	
+base_bom_grandchild = [
+	{"doctype": "BOM", "item": "Android Jack S", "quantity": 1,
+		"is_active": "Yes", "is_default": 1, "uom": "Nos"},
+	{"doctype": "BOM Operation", "operation_no": 1, "parentfield": "bom_operations",
+		"opn_description": "Development"}, 
+	{"doctype": "BOM Item", "item_code": "Home Desktop 300", "operation_no": 1, 
+		"qty": 3, "rate": 10, "stock_uom": "Nos", 	"parentfield": "bom_materials"}
+]
+
+
+class TestPurchaseReceipt(unittest.TestCase):
+	def setUp(self):
+		webnotes.conn.begin()
+		load_data()
+		
+	def test_bom_validation(self):
+		# show throw error bacause bom no missing for sub-assembly item
+		bom_fg = copy.deepcopy(base_bom_fg)
+		self.assertRaises(webnotes.ValidationError, webnotes.insert, DocList(bom_fg))
+
+		# main item is not a manufacturing item
+		bom_fg = copy.deepcopy(base_bom_fg)
+		bom_fg[0]["item"] = "Home Desktop 200"
+		bom_fg.pop(4)
+		self.assertRaises(webnotes.ValidationError, webnotes.insert, DocList(bom_fg))
+		
+		# operation no mentioed in material table not matching with operation table
+		bom_fg = copy.deepcopy(base_bom_fg)
+		bom_fg.pop(4)
+		bom_fg[2]["operation_no"] = 2
+		self.assertRaises(webnotes.ValidationError, webnotes.insert, DocList(bom_fg))
+		
+	
+	def test_bom(self):
+		gc_wrapper = webnotes.insert(DocList(base_bom_grandchild))
+		gc_wrapper.submit()
+		
+		bom_child = copy.deepcopy(base_bom_child)
+		bom_child[2]["bom_no"] = gc_wrapper.doc.name
+		child_wrapper = webnotes.insert(DocList(bom_child))
+		child_wrapper.submit()
+		
+		bom_fg = copy.deepcopy(base_bom_fg)
+		bom_fg[4]["bom_no"] = child_wrapper.doc.name
+		fg_wrapper = webnotes.insert(DocList(bom_fg))
+		fg_wrapper.load_from_db()
+		
+		self.check_bom_cost(fg_wrapper)
+		
+		self.check_flat_bom(fg_wrapper, child_wrapper, gc_wrapper)
+		
+	def check_bom_cost(self, fg_wrapper):
+		expected_values = {
+			"operating_cost": 15,
+			"raw_material_cost": 640,
+			"total_cost": 655
+		}
+
+		for key in expected_values:
+			self.assertEqual(flt(expected_values[key]), flt(fg_wrapper.doc.fields.get(key)))
+			
+	def check_flat_bom(self, fg_wrapper, child_wrapper, gc_wrapper):
+		expected_flat_bom_items = {
+			("Home Desktop 300", fg_wrapper.doc.name): (2, 20),
+			("Home Desktop 100", fg_wrapper.doc.name): (1, 300),
+			("Home Desktop 300", gc_wrapper.doc.name): (30, 10)
+		}
+		
+		self.assertEqual(len(fg_wrapper.doclist.get({"parentfield": "flat_bom_details"})), 3)
+		
+		for key, val in expected_flat_bom_items.items():
+			flat_bom = fg_wrapper.doclist.get({"parentfield": "flat_bom_details", 
+				"item_code": key[0], "parent_bom": key[1]})[0]
+			self.assertEqual(val, (flat_bom.qty, flat_bom.rate))
+		
+		
+	def tearDown(self):
+		webnotes.conn.rollback()
\ No newline at end of file
diff --git a/production/doctype/bom_explosion_item/__init__.py b/manufacturing/doctype/bom_explosion_item/__init__.py
similarity index 100%
rename from production/doctype/bom_explosion_item/__init__.py
rename to manufacturing/doctype/bom_explosion_item/__init__.py
diff --git a/production/doctype/bom_explosion_item/bom_explosion_item.py b/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py
similarity index 100%
rename from production/doctype/bom_explosion_item/bom_explosion_item.py
rename to manufacturing/doctype/bom_explosion_item/bom_explosion_item.py
diff --git a/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt b/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt
new file mode 100644
index 0000000..4d88a8f
--- /dev/null
+++ b/manufacturing/doctype/bom_explosion_item/bom_explosion_item.txt
@@ -0,0 +1,107 @@
+[
+ {
+  "owner": "Administrator", 
+  "docstatus": 0, 
+  "creation": "2012-07-03 13:30:04", 
+  "modified_by": "Administrator", 
+  "modified": "2012-12-10 18:30:00"
+ }, 
+ {
+  "read_only": 0, 
+  "istable": 1, 
+  "autoname": "FBD/.######", 
+  "name": "__common__", 
+  "default_print_format": "Standard", 
+  "doctype": "DocType", 
+  "module": "Manufacturing"
+ }, 
+ {
+  "name": "__common__", 
+  "parent": "BOM Explosion Item", 
+  "doctype": "DocField", 
+  "parenttype": "DocType", 
+  "permlevel": 1, 
+  "parentfield": "fields"
+ }, 
+ {
+  "name": "BOM Explosion Item", 
+  "doctype": "DocType"
+ }, 
+ {
+  "oldfieldtype": "Link", 
+  "doctype": "DocField", 
+  "label": "Item Code", 
+  "oldfieldname": "item_code", 
+  "fieldname": "item_code", 
+  "fieldtype": "Link", 
+  "options": "Item"
+ }, 
+ {
+  "oldfieldtype": "Text", 
+  "doctype": "DocField", 
+  "label": "Description", 
+  "oldfieldname": "description", 
+  "width": "300px", 
+  "fieldname": "description", 
+  "fieldtype": "Text"
+ }, 
+ {
+  "oldfieldtype": "Currency", 
+  "doctype": "DocField", 
+  "label": "Qty", 
+  "oldfieldname": "qty", 
+  "fieldname": "qty", 
+  "fieldtype": "Float"
+ }, 
+ {
+  "oldfieldtype": "Currency", 
+  "doctype": "DocField", 
+  "label": "Rate", 
+  "oldfieldname": "standard_rate", 
+  "fieldname": "rate", 
+  "fieldtype": "Float"
+ }, 
+ {
+  "oldfieldtype": "Currency", 
+  "doctype": "DocField", 
+  "label": "Amount", 
+  "oldfieldname": "amount_as_per_sr", 
+  "fieldname": "amount", 
+  "fieldtype": "Float"
+ }, 
+ {
+  "oldfieldtype": "Link", 
+  "doctype": "DocField", 
+  "label": "Stock UOM", 
+  "oldfieldname": "stock_uom", 
+  "fieldname": "stock_uom", 
+  "fieldtype": "Link", 
+  "options": "UOM"
+ }, 
+ {
+  "oldfieldtype": "Link", 
+  "doctype": "DocField", 
+  "label": "Parent BOM", 
+  "oldfieldname": "parent_bom", 
+  "width": "250px", 
+  "fieldname": "parent_bom", 
+  "fieldtype": "Link", 
+  "hidden": 0, 
+  "options": "BOM"
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Mat Detail No", 
+  "fieldname": "mat_detail_no", 
+  "fieldtype": "Data", 
+  "hidden": 1
+ }, 
+ {
+  "no_copy": 0, 
+  "doctype": "DocField", 
+  "label": "Qty Consumed Per Unit", 
+  "fieldname": "qty_consumed_per_unit", 
+  "fieldtype": "Float", 
+  "hidden": 0
+ }
+]
\ No newline at end of file
diff --git a/production/doctype/bom_item/__init__.py b/manufacturing/doctype/bom_item/__init__.py
similarity index 100%
rename from production/doctype/bom_item/__init__.py
rename to manufacturing/doctype/bom_item/__init__.py
diff --git a/production/doctype/bom_item/bom_item.py b/manufacturing/doctype/bom_item/bom_item.py
similarity index 100%
rename from production/doctype/bom_item/bom_item.py
rename to manufacturing/doctype/bom_item/bom_item.py
diff --git a/production/doctype/bom_item/bom_item.txt b/manufacturing/doctype/bom_item/bom_item.txt
similarity index 97%
rename from production/doctype/bom_item/bom_item.txt
rename to manufacturing/doctype/bom_item/bom_item.txt
index 4204b20..e75625a 100644
--- a/production/doctype/bom_item/bom_item.txt
+++ b/manufacturing/doctype/bom_item/bom_item.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-03-27 14:36:02',
 		'docstatus': 0,
-		'modified': '2012-03-27 14:36:02',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -15,7 +15,7 @@
 		'colour': u'White:FFF',
 		'doctype': 'DocType',
 		'istable': 1,
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
 		'section_style': u'Simple',
 		'server_code_error': u' ',
diff --git a/production/doctype/bom_operation/__init__.py b/manufacturing/doctype/bom_operation/__init__.py
similarity index 100%
rename from production/doctype/bom_operation/__init__.py
rename to manufacturing/doctype/bom_operation/__init__.py
diff --git a/production/doctype/bom_operation/bom_operation.py b/manufacturing/doctype/bom_operation/bom_operation.py
similarity index 100%
rename from production/doctype/bom_operation/bom_operation.py
rename to manufacturing/doctype/bom_operation/bom_operation.py
diff --git a/production/doctype/bom_operation/bom_operation.txt b/manufacturing/doctype/bom_operation/bom_operation.txt
similarity index 96%
rename from production/doctype/bom_operation/bom_operation.txt
rename to manufacturing/doctype/bom_operation/bom_operation.txt
index b09856d..082306d 100644
--- a/production/doctype/bom_operation/bom_operation.txt
+++ b/manufacturing/doctype/bom_operation/bom_operation.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-03-27 14:36:02',
 		'docstatus': 0,
-		'modified': '2012-03-27 14:36:02',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -15,7 +15,7 @@
 		'colour': u'White:FFF',
 		'doctype': 'DocType',
 		'istable': 1,
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
 		'section_style': u'Simple',
 		'server_code_error': u' ',
diff --git a/manufacturing/doctype/bom_replace_tool/__init__.py b/manufacturing/doctype/bom_replace_tool/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/manufacturing/doctype/bom_replace_tool/__init__.py
diff --git a/production/page/production_home/production_home.js b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.js
similarity index 76%
copy from production/page/production_home/production_home.js
copy to manufacturing/doctype/bom_replace_tool/bom_replace_tool.js
index a4bb398..60e8884 100644
--- a/production/page/production_home/production_home.js
+++ b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.js
@@ -14,7 +14,12 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-pscript['onload_production-home'] = function(wrapper) {
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Production');
-	erpnext.module_page.setup_page('Production', wrapper);
-}
\ No newline at end of file
+
+cur_frm.set_query("current_bom", function(doc) {
+	return erpnext.queries.bom({name: "!" + doc.new_bom});
+});
+
+
+cur_frm.set_query("new_bom", function(doc) {
+	return erpnext.queries.bom({name: "!" + doc.current_bom});
+});
\ No newline at end of file
diff --git a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
new file mode 100644
index 0000000..d9d9598
--- /dev/null
+++ b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
@@ -0,0 +1,56 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes.utils import cstr, flt
+from webnotes.model.code import get_obj
+from webnotes import msgprint
+	
+class DocType:
+	def __init__( self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		
+	def replace_bom(self):
+		self.validate_bom()
+		self.update_new_bom()
+		bom_list = self.get_parent_boms()
+		for bom in bom_list:
+			bom_obj = get_obj("BOM", bom, with_children=1)
+			bom_obj.update_cost_by_traversing()
+			bom_obj.update_flat_bom_by_traversing()
+		
+	def validate_bom(self):
+		if cstr(self.doc.current_bom) == cstr(self.doc.new_bom):
+			msgprint("Current BOM and New BOM can not be same", raise_exception=1)
+	
+	def update_new_bom(self):
+		current_bom_unitcost = webnotes.conn.sql("""select total_cost/quantity 
+			from `tabBOM` where name = %s""", self.doc.current_bom)
+		current_bom_unitcost = current_bom_unitcost and flt(current_bom_unitcost[0][0]) or 0
+		webnotes.conn.sql("""update `tabBOM Item` set bom_no=%s, 
+			rate=%s, amount=qty*%s where bom_no = %s and docstatus < 2""", 
+			(self.doc.new_bom, current_bom_unitcost, current_bom_unitcost, self.doc.current_bom))
+			
+	def get_parent_boms(bom_no):
+		return [d[0] for d in webnotes.conn.sql("""select distinct parent from
+			`tabBOM Item` where ifnull(bom_no, '')=%s and docstatus < 2""", bom_no)]
+	
+	def get_parent_boms(self):
+		return [d[0] for d in webnotes.conn.sql("""select distinct parent 
+			from `tabBOM Item` where ifnull(bom_no, '') = %s and docstatus < 2""",
+			self.doc.new_bom)]
\ No newline at end of file
diff --git a/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt
new file mode 100644
index 0000000..bb2c56b
--- /dev/null
+++ b/manufacturing/doctype/bom_replace_tool/bom_replace_tool.txt
@@ -0,0 +1,78 @@
+[
+ {
+  "owner": "Administrator", 
+  "docstatus": 0, 
+  "creation": "2012-12-06 12:10:10", 
+  "modified_by": "Administrator", 
+  "modified": "2012-12-06 12:32:22"
+ }, 
+ {
+  "in_create": 1, 
+  "allow_print": 1, 
+  "module": "Production", 
+  "document_type": "Other", 
+  "description": "Replace a particular BOM in all other BOMs where it is used. It will replace the old BOM link, update cost and regenerate \"BOM Explosion Item\" table as per new BOM", 
+  "read_only": 1, 
+  "allow_email": 1, 
+  "hide_heading": 1, 
+  "issingle": 1, 
+  "name": "__common__", 
+  "doctype": "DocType", 
+  "hide_toolbar": 1, 
+  "allow_copy": 1
+ }, 
+ {
+  "name": "__common__", 
+  "parent": "BOM Replace Tool", 
+  "doctype": "DocField", 
+  "parenttype": "DocType", 
+  "permlevel": 0, 
+  "parentfield": "fields"
+ }, 
+ {
+  "parent": "BOM Replace Tool", 
+  "read": 1, 
+  "name": "__common__", 
+  "create": 1, 
+  "doctype": "DocPerm", 
+  "write": 1, 
+  "parenttype": "DocType", 
+  "role": "Administrator", 
+  "permlevel": 0, 
+  "parentfield": "permissions"
+ }, 
+ {
+  "name": "BOM Replace Tool", 
+  "doctype": "DocType"
+ }, 
+ {
+  "description": "The BOM which will be replaced", 
+  "colour": "White:FFF", 
+  "doctype": "DocField", 
+  "label": "Current BOM", 
+  "fieldname": "current_bom", 
+  "fieldtype": "Link", 
+  "reqd": 1, 
+  "options": "BOM"
+ }, 
+ {
+  "description": "The new BOM after replacement", 
+  "colour": "White:FFF", 
+  "doctype": "DocField", 
+  "label": "New BOM", 
+  "fieldname": "new_bom", 
+  "fieldtype": "Link", 
+  "reqd": 1, 
+  "options": "BOM"
+ }, 
+ {
+  "doctype": "DocField", 
+  "label": "Replace", 
+  "fieldname": "replace", 
+  "fieldtype": "Button", 
+  "options": "replace_bom"
+ }, 
+ {
+  "doctype": "DocPerm"
+ }
+]
\ No newline at end of file
diff --git a/production/doctype/production_order/__init__.py b/manufacturing/doctype/production_order/__init__.py
similarity index 100%
rename from production/doctype/production_order/__init__.py
rename to manufacturing/doctype/production_order/__init__.py
diff --git a/production/doctype/production_order/production_order.js b/manufacturing/doctype/production_order/production_order.js
similarity index 90%
rename from production/doctype/production_order/production_order.js
rename to manufacturing/doctype/production_order/production_order.js
index 7949757..85d9633 100644
--- a/production/doctype/production_order/production_order.js
+++ b/manufacturing/doctype/production_order/production_order.js
@@ -92,12 +92,9 @@
 	  AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
 }
 
-cur_frm.fields_dict['bom_no'].get_query = function(doc)  {
-  if (doc.production_item){
-    return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 AND `tabBOM`.`item` = "' + cstr(doc.production_item) + '" AND`tabBOM`.%(key)s LIKE "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
-  }
-  else {
-    alert(" Please Enter Production Item First.")
-  }
-}
 
+cur_frm.set_query("bom_no", function(doc) {
+	if (doc.production_item) {
+		return erpnext.queries.bom({item: cstr(doc.production_item)});
+	} else msgprint(" Please enter Production Item first");
+});
\ No newline at end of file
diff --git a/production/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py
similarity index 77%
rename from production/doctype/production_order/production_order.py
rename to manufacturing/doctype/production_order/production_order.py
index 5314971..07073da 100644
--- a/production/doctype/production_order/production_order.py
+++ b/manufacturing/doctype/production_order/production_order.py
@@ -72,8 +72,33 @@
 					where name=%s and docstatus = 1""", self.doc.sales_order):
 				msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1)
 				
-			get_obj("Production Control").validate_production_order_against_so(
-				self.doc.production_item, self.doc.sales_order, self.doc.qty, self.doc.name)
+			self.validate_production_order_against_so()
+				
+	
+	def validate_production_order_against_so(self):
+		# already ordered qty
+		ordered_qty_against_so = webnotes.conn.sql("""select sum(qty) from `tabProduction Order`
+			where production_item = %s and sales_order = %s and docstatus < 2""", 
+			(self.doc.production_item, self.doc.sales_order))[0][0]
+
+		
+		# get qty from Sales Order Item table
+		so_item_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item` 
+			where parent = %s and item_code = %s""", 
+			(self.doc.sales_order, self.doc.production_item))[0][0]
+		# get qty from Packing Item table
+		dnpi_qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Packing Item` 
+			where parent = %s and parenttype = 'Sales Order' and item_code = %s""", 
+			(self.doc.sales_order, self.doc.production_item))[0][0]
+		# total qty in SO
+		so_qty = flt(so_item_qty) + flt(dnpi_qty)
+		
+		if ordered_qty_against_so > so_qty:
+			msgprint("""Total production order qty for item: %s against sales order: %s \
+			 	will be %s, which is greater than sales order qty (%s). 
+				Please reduce qty or remove the item.""" %
+				(self.doc.production_item, self.doc.sales_order, 
+					ordered_qty_against_so, so_qty), raise_exception=1)
 
 
 	def stop_unstop(self, status):
diff --git a/production/doctype/production_order/production_order.txt b/manufacturing/doctype/production_order/production_order.txt
similarity index 97%
rename from production/doctype/production_order/production_order.txt
rename to manufacturing/doctype/production_order/production_order.txt
index 64d0bad..65ae4b8 100644
--- a/production/doctype/production_order/production_order.txt
+++ b/manufacturing/doctype/production_order/production_order.txt
@@ -4,13 +4,13 @@
   "docstatus": 0, 
   "creation": "2012-07-03 13:30:03", 
   "modified_by": "Administrator", 
-  "modified": "2012-12-03 15:38:54"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "is_submittable": 1, 
   "in_create": 0, 
   "doctype": "DocType", 
-  "module": "Production", 
+  "module": "Manufacturing", 
   "name": "__common__"
  }, 
  {
@@ -306,7 +306,7 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "cancel": 1, 
   "permlevel": 0
  }, 
@@ -316,7 +316,7 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "cancel": 1, 
   "permlevel": 0
  }
diff --git a/production/doctype/production_order/production_order_list.js b/manufacturing/doctype/production_order/production_order_list.js
similarity index 100%
rename from production/doctype/production_order/production_order_list.js
rename to manufacturing/doctype/production_order/production_order_list.js
diff --git a/production/doctype/production_plan_item/__init__.py b/manufacturing/doctype/production_plan_item/__init__.py
similarity index 100%
rename from production/doctype/production_plan_item/__init__.py
rename to manufacturing/doctype/production_plan_item/__init__.py
diff --git a/production/doctype/production_plan_item/production_plan_item.py b/manufacturing/doctype/production_plan_item/production_plan_item.py
similarity index 100%
rename from production/doctype/production_plan_item/production_plan_item.py
rename to manufacturing/doctype/production_plan_item/production_plan_item.py
diff --git a/production/doctype/production_plan_item/production_plan_item.txt b/manufacturing/doctype/production_plan_item/production_plan_item.txt
similarity index 96%
rename from production/doctype/production_plan_item/production_plan_item.txt
rename to manufacturing/doctype/production_plan_item/production_plan_item.txt
index b2cbf8d..ab3ce11 100644
--- a/production/doctype/production_plan_item/production_plan_item.txt
+++ b/manufacturing/doctype/production_plan_item/production_plan_item.txt
@@ -4,14 +4,14 @@
   "docstatus": 0, 
   "creation": "2012-07-03 13:30:04", 
   "modified_by": "Administrator", 
-  "modified": "2012-11-29 19:02:38"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "istable": 1, 
   "autoname": "PPID/.#####", 
   "name": "__common__", 
   "doctype": "DocType", 
-  "module": "Production"
+  "module": "Manufacturing"
  }, 
  {
   "name": "__common__", 
diff --git a/production/doctype/production_plan_sales_order/__init__.py b/manufacturing/doctype/production_plan_sales_order/__init__.py
similarity index 100%
rename from production/doctype/production_plan_sales_order/__init__.py
rename to manufacturing/doctype/production_plan_sales_order/__init__.py
diff --git a/production/doctype/production_plan_sales_order/production_plan_sales_order.py b/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py
similarity index 100%
rename from production/doctype/production_plan_sales_order/production_plan_sales_order.py
rename to manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py
diff --git a/production/doctype/production_plan_sales_order/production_plan_sales_order.txt b/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt
similarity index 95%
rename from production/doctype/production_plan_sales_order/production_plan_sales_order.txt
rename to manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt
index 79adc14..37e0f8a 100644
--- a/production/doctype/production_plan_sales_order/production_plan_sales_order.txt
+++ b/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.txt
@@ -4,14 +4,14 @@
   "docstatus": 0, 
   "creation": "2012-07-03 13:30:04", 
   "modified_by": "Administrator", 
-  "modified": "2012-11-29 17:49:15"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "istable": 1, 
   "autoname": "PP/.SO/.#####", 
   "name": "__common__", 
   "doctype": "DocType", 
-  "module": "Production"
+  "module": "Manufacturing"
  }, 
  {
   "name": "__common__", 
diff --git a/production/doctype/production_planning_tool/__init__.py b/manufacturing/doctype/production_planning_tool/__init__.py
similarity index 100%
rename from production/doctype/production_planning_tool/__init__.py
rename to manufacturing/doctype/production_planning_tool/__init__.py
diff --git a/production/doctype/production_planning_tool/production_planning_tool.js b/manufacturing/doctype/production_planning_tool/production_planning_tool.js
similarity index 90%
rename from production/doctype/production_planning_tool/production_planning_tool.js
rename to manufacturing/doctype/production_planning_tool/production_planning_tool.js
index ac4d76d..970da65 100644
--- a/production/doctype/production_planning_tool/production_planning_tool.js
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.js
@@ -51,10 +51,9 @@
 
 cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc) {
 	var d = locals[this.doctype][this.docname];
-  	return 'SELECT DISTINCT `tabBOM`.`name` \
-		FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code + 
-		'" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 \
-		AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
+	if (d.item_code) {
+		return erpnext.queries.bom({item: cstr(d.item_code)});
+	} else msgprint(" Please enter Item first");
 }
 
 cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
diff --git a/production/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
similarity index 90%
rename from production/doctype/production_planning_tool/production_planning_tool.py
rename to manufacturing/doctype/production_planning_tool/production_planning_tool.py
index 64ac73d..fb87fb2 100644
--- a/production/doctype/production_planning_tool/production_planning_tool.py
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -16,8 +16,8 @@
 
 from __future__ import unicode_literals
 import webnotes
-from webnotes.utils import cstr, flt
-from webnotes.model.doc import addchild
+from webnotes.utils import cstr, flt, nowdate, get_defaults
+from webnotes.model.doc import addchild, Document
 from webnotes.model.wrapper import getlist
 from webnotes.model.code import get_obj
 from webnotes import msgprint
@@ -186,7 +186,7 @@
 		self.validate_data()
 
 		items = self.get_distinct_items_and_boms()[1]
-		pro = get_obj('Production Control').create_production_order(items)
+		pro = self.create_production_order(items)
 		if pro:
 			msgprint("Following Production Order has been generated:\n" + '\n'.join(pro))
 		else :
@@ -199,15 +199,39 @@
 		for d in self.doclist.get({"parentfield": "pp_details"}):
 			bom_dict[d.bom_no] = bom_dict.get(d.bom_no, 0) + flt(d.planned_qty)
 			item_dict[(d.item_code, d.sales_order)] = {
-				"qty" : flt(item_dict.get((d.item_code, d.sales_order), {}).get("qty")) + \
-				 	flt(d.planned_qty),
-				"bom_no": d.bom_no,
-				"description": d.description,
-				"stock_uom": d.stock_uom,
+				"qty" 				: flt(item_dict.get((d.item_code, d.sales_order), \
+					{}).get("qty")) + flt(d.planned_qty),
+				"bom_no"			: d.bom_no,
+				"description"		: d.description,
+				"stock_uom"			: d.stock_uom,
 				"use_multi_level_bom": self.doc.use_multi_level_bom,
-				"company": self.doc.company,
+				"company"			: self.doc.company,
+				"posting_date"		: nowdate(),
+				"origin"			: "MRP",
+				"wip_warehouse"		: "",
+				"fg_warehouse"		: "",
+				"status"			: "Draft",
+				"fiscal_year"		: get_defaults()["fiscal_year"]
 			}
 		return bom_dict, item_dict
+		
+	def create_production_order(self, items):
+		"""Create production order. Called from Production Planning Tool"""
+
+		pro_list = []
+		for item_so in items:
+			pro_doc = Document('Production Order')
+			pro_doc.production_item = item_so[0]
+			pro_doc.sales_order = item_so[1]
+			for key in items[item_so]:
+				pro_doc.fields[key] = items[item_so][key]
+			
+			pro_doc.save(new = 1)
+			
+			get_obj("Production Order", pro_doc.name).validate_production_order_against_so()
+			pro_list.append(pro_doc.name)
+			
+		return pro_list
 
 	def download_raw_materials(self):
 		""" Create csv data for required raw material to produce finished goods"""
diff --git a/production/doctype/production_planning_tool/production_planning_tool.txt b/manufacturing/doctype/production_planning_tool/production_planning_tool.txt
similarity index 97%
rename from production/doctype/production_planning_tool/production_planning_tool.txt
rename to manufacturing/doctype/production_planning_tool/production_planning_tool.txt
index 9bda9ab..dcec425 100644
--- a/production/doctype/production_planning_tool/production_planning_tool.txt
+++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.txt
@@ -4,14 +4,14 @@
   "docstatus": 0, 
   "creation": "2012-07-03 13:30:03", 
   "modified_by": "Administrator", 
-  "modified": "2012-12-03 15:39:44"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "read_only": 1, 
   "issingle": 1, 
   "in_create": 1, 
   "doctype": "DocType", 
-  "module": "Production", 
+  "module": "Manufacturing", 
   "name": "__common__"
  }, 
  {
@@ -208,11 +208,11 @@
   "doctype": "DocPerm"
  }, 
  {
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "doctype": "DocPerm"
  }, 
  {
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "doctype": "DocPerm"
  }
 ]
\ No newline at end of file
diff --git a/production/doctype/workstation/__init__.py b/manufacturing/doctype/workstation/__init__.py
similarity index 100%
rename from production/doctype/workstation/__init__.py
rename to manufacturing/doctype/workstation/__init__.py
diff --git a/production/doctype/workstation/workstation.js b/manufacturing/doctype/workstation/workstation.js
similarity index 100%
rename from production/doctype/workstation/workstation.js
rename to manufacturing/doctype/workstation/workstation.js
diff --git a/production/doctype/workstation/workstation.py b/manufacturing/doctype/workstation/workstation.py
similarity index 100%
rename from production/doctype/workstation/workstation.py
rename to manufacturing/doctype/workstation/workstation.py
diff --git a/production/doctype/workstation/workstation.txt b/manufacturing/doctype/workstation/workstation.txt
similarity index 95%
rename from production/doctype/workstation/workstation.txt
rename to manufacturing/doctype/workstation/workstation.txt
index f625971..12b4b20 100644
--- a/production/doctype/workstation/workstation.txt
+++ b/manufacturing/doctype/workstation/workstation.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-03-27 14:36:05',
 		'docstatus': 0,
-		'modified': '2012-03-27 18:46:49',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -19,7 +19,7 @@
 		'colour': u'White:FFF',
 		'doctype': 'DocType',
 		'document_type': u'Master',
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
 		'section_style': u'Simple',
 		'server_code_error': u' ',
@@ -75,7 +75,7 @@
 		'create': 1,
 		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': u'Production User',
+		'role': u'Manufacturing User',
 		'write': 1
 	},
 
@@ -85,7 +85,7 @@
 		'create': 1,
 		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': u'Production User',
+		'role': u'Manufacturing User',
 		'write': 1
 	},
 
@@ -93,14 +93,14 @@
 	{
 		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': u'Production Manager'
+		'role': u'Manufacturing Manager'
 	},
 
 	# DocPerm
 	{
 		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': u'Production User'
+		'role': u'Manufacturing User'
 	},
 
 	# DocField
diff --git a/production/page/__init__.py b/manufacturing/page/__init__.py
similarity index 100%
rename from production/page/__init__.py
rename to manufacturing/page/__init__.py
diff --git a/production/page/production_home/__init__.py b/manufacturing/page/manufacturing_home/__init__.py
similarity index 100%
rename from production/page/production_home/__init__.py
rename to manufacturing/page/manufacturing_home/__init__.py
diff --git a/production/page/production_home/production_home.html b/manufacturing/page/manufacturing_home/manufacturing_home.html
similarity index 80%
rename from production/page/production_home/production_home.html
rename to manufacturing/page/manufacturing_home/manufacturing_home.html
index 50f99b3..4ac410c 100644
--- a/production/page/production_home/production_home.html
+++ b/manufacturing/page/manufacturing_home/manufacturing_home.html
@@ -23,6 +23,16 @@
 	<div class="layout-side-section">
 		<div class="psidebar">
 			<div class="section">
+				<div class="section-head">Tools</div>
+				<div class="section-body">
+					<div class="section-item">
+						<a class="section-link" 
+							title = "BOM Replace Tool"
+							href="#!Form/BOM Replace Tool">BOM Replace Tool</a>
+					</div>
+				</div>
+			</div>
+			<div class="section">
 				<div class="section-head">Setup</div>
 				<div class="section-body">
 					<div class="section-item">
diff --git a/production/page/production_home/production_home.js b/manufacturing/page/manufacturing_home/manufacturing_home.js
similarity index 84%
rename from production/page/production_home/production_home.js
rename to manufacturing/page/manufacturing_home/manufacturing_home.js
index a4bb398..ee4778d 100644
--- a/production/page/production_home/production_home.js
+++ b/manufacturing/page/manufacturing_home/manufacturing_home.js
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-pscript['onload_production-home'] = function(wrapper) {
-	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Production');
-	erpnext.module_page.setup_page('Production', wrapper);
+pscript['onload_manufacturing-home'] = function(wrapper) {
+	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Manufacturing');
+	erpnext.module_page.setup_page('Manufacturing', wrapper);
 }
\ No newline at end of file
diff --git a/production/page/production_home/production_home.txt b/manufacturing/page/manufacturing_home/manufacturing_home.txt
similarity index 67%
rename from production/page/production_home/production_home.txt
rename to manufacturing/page/manufacturing_home/manufacturing_home.txt
index 4f6cabb..33cf034 100644
--- a/production/page/production_home/production_home.txt
+++ b/manufacturing/page/manufacturing_home/manufacturing_home.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-02-21 13:24:34',
 		'docstatus': 0,
-		'modified': '2012-02-21 13:24:34',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -13,16 +13,16 @@
 	# These values are common for all Page
 	{
 		'doctype': 'Page',
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
-		'page_name': u'production-home',
+		'page_name': u'manufacturing-home',
 		'standard': u'Yes',
-		'title': u'Production Home'
+		'title': u'Manufacturing Home'
 	},
 
 	# Page, production-home
 	{
 		'doctype': 'Page',
-		'name': u'production-home'
+		'name': u'manufacturing-home'
 	}
 ]
\ No newline at end of file
diff --git a/production/search_criteria/__init__.py b/manufacturing/search_criteria/__init__.py
similarity index 100%
rename from production/search_criteria/__init__.py
rename to manufacturing/search_criteria/__init__.py
diff --git a/production/search_criteria/consumption_against_production/__init__.py b/manufacturing/search_criteria/consumption_against_production/__init__.py
similarity index 100%
rename from production/search_criteria/consumption_against_production/__init__.py
rename to manufacturing/search_criteria/consumption_against_production/__init__.py
diff --git a/production/search_criteria/consumption_against_production/consumption_against_production.txt b/manufacturing/search_criteria/consumption_against_production/consumption_against_production.txt
similarity index 95%
rename from production/search_criteria/consumption_against_production/consumption_against_production.txt
rename to manufacturing/search_criteria/consumption_against_production/consumption_against_production.txt
index 54d6a19..d1aa517 100644
--- a/production/search_criteria/consumption_against_production/consumption_against_production.txt
+++ b/manufacturing/search_criteria/consumption_against_production/consumption_against_production.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-04-03 12:49:50',
 		'docstatus': 0,
-		'modified': '2012-04-03 12:49:50',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'jai@webnotestech.com'
 	},
@@ -20,7 +20,7 @@
 		'doc_type': u'Stock Entry Detail',
 		'doctype': 'Search Criteria',
 		'filters': u"{'Stock Entry\x01Submitted':1,'Stock Entry\x01Purpose':'Production Order','Stock Entry\x01Process':''}",
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
 		'page_len': 50,
 		'parent_doc_type': u'Stock Entry',
diff --git a/production/search_criteria/itemwise_production_report/__init__.py b/manufacturing/search_criteria/itemwise_production_report/__init__.py
similarity index 100%
rename from production/search_criteria/itemwise_production_report/__init__.py
rename to manufacturing/search_criteria/itemwise_production_report/__init__.py
diff --git a/production/search_criteria/itemwise_production_report/itemwise_production_report.js b/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.js
similarity index 100%
rename from production/search_criteria/itemwise_production_report/itemwise_production_report.js
rename to manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.js
diff --git a/production/search_criteria/itemwise_production_report/itemwise_production_report.txt b/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.txt
similarity index 94%
rename from production/search_criteria/itemwise_production_report/itemwise_production_report.txt
rename to manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.txt
index 6f0c3eb..46828c7 100644
--- a/production/search_criteria/itemwise_production_report/itemwise_production_report.txt
+++ b/manufacturing/search_criteria/itemwise_production_report/itemwise_production_report.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-04-03 12:49:51',
 		'docstatus': 0,
-		'modified': '2012-04-03 12:49:51',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'jai@webnotestech.com'
 	},
@@ -17,7 +17,7 @@
 		'doc_type': u'Stock Entry Detail',
 		'doctype': 'Search Criteria',
 		'filters': u"{'Stock Entry\x01Saved':1,'Stock Entry\x01Submitted':1,'Stock Entry\x01Purpose':'Production Order','Stock Entry\x01Process':'Backflush','Stock Entry Detail\x01FG Item':1}",
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
 		'page_len': 50,
 		'parent_doc_type': u'Stock Entry',
diff --git a/production/search_criteria/production_orders_in_process/__init__.py b/manufacturing/search_criteria/production_orders_in_process/__init__.py
similarity index 100%
rename from production/search_criteria/production_orders_in_process/__init__.py
rename to manufacturing/search_criteria/production_orders_in_process/__init__.py
diff --git a/production/search_criteria/production_orders_in_process/production_orders_in_process.txt b/manufacturing/search_criteria/production_orders_in_process/production_orders_in_process.txt
similarity index 95%
rename from production/search_criteria/production_orders_in_process/production_orders_in_process.txt
rename to manufacturing/search_criteria/production_orders_in_process/production_orders_in_process.txt
index 51eb1f4..d61fff1 100644
--- a/production/search_criteria/production_orders_in_process/production_orders_in_process.txt
+++ b/manufacturing/search_criteria/production_orders_in_process/production_orders_in_process.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-04-03 12:49:52',
 		'docstatus': 0,
-		'modified': '2012-04-03 12:49:52',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'jai@webnotestech.com'
 	},
@@ -18,7 +18,7 @@
 		'doc_type': u'Production Order',
 		'doctype': 'Search Criteria',
 		'filters': u"{'Production Order\x01Submitted':1,'Production Order\x01Origin':'','Production Order\x01Status':'','Production Order\x01Consider SA Items':'','Production Order\x01Fiscal Year':''}",
-		'module': u'Production',
+		'module': u'Manufacturing',
 		'name': '__common__',
 		'page_len': 50,
 		'sort_by': u'`tabProduction Order`.`name`',
diff --git a/patches/before_jan_2012/Discount_purchase_cycle.py b/patches/before_jan_2012/Discount_purchase_cycle.py
deleted file mode 100644
index 8ddcbf5..0000000
--- a/patches/before_jan_2012/Discount_purchase_cycle.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('accounts', 'doctype', 'pv_detail')
-	reload_doc('buying', 'doctype', 'po_detail')
-	reload_doc('stock', 'doctype', 'purchase_receipt_detail')
-	if webnotes.conn.sql("select name from `tabDocField` where parent = 'Purchase Order Item' and fieldname = 'discount'"):
-		webnotes.conn.sql("update `tabPurchase Order Item` set discount_rate=discount")
-
-	# Features setup
-	reload_doc('setup', 'doctype', 'features_setup')
-	from webnotes.model.code import get_obj
-	get_obj('Features Setup').validate()
diff --git a/patches/before_jan_2012/__init__.py b/patches/before_jan_2012/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/patches/before_jan_2012/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/patches/before_jan_2012/accounts_default_form.py b/patches/before_jan_2012/accounts_default_form.py
deleted file mode 100644
index 51e41aa..0000000
--- a/patches/before_jan_2012/accounts_default_form.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-        import webnotes
-        from webnotes.modules import reload_doc
-        reload_doc('setup', 'doctype', 'company')
-        reload_doc('setup', 'doctype', 'manage_account')
- 
diff --git a/patches/before_jan_2012/auto_indent.py b/patches/before_jan_2012/auto_indent.py
deleted file mode 100644
index 6018681..0000000
--- a/patches/before_jan_2012/auto_indent.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('setup', 'doctype', 'manage_account')
-	reload_doc('stock', 'doctype', 'item')
-	webnotes.conn.sql("delete from `tabDocField` where fieldname='minimum_inventory_level' and parent='item'")
-	webnotes.conn.sql("update `tabItem` set re_order_level = minimum_inventory_level where ifnull(re_order_level,0) = 0 ")
-		
diff --git a/patches/before_jan_2012/c_form_patch.py b/patches/before_jan_2012/c_form_patch.py
deleted file mode 100644
index 37b9983..0000000
--- a/patches/before_jan_2012/c_form_patch.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('accounts', 'doctype', 'receivable_voucher')
-	reload_doc('accounts', 'doctype', 'c_form')
-	reload_doc('accounts', 'doctype', 'c_form_invoice_detail')
-	reload_doc('accounts', 'Module Def', 'Accounts')
-
-	sql = webnotes.conn.sql
-	sql("update `tabSales Invoice` set c_form_applicable = 'Yes' where c_form_applicable = 'Y'")
-	sql("update `tabSales Invoice` set c_form_applicable = 'No' where c_form_applicable = 'N'")
diff --git a/patches/before_jan_2012/delivery_billing_status_patch.py b/patches/before_jan_2012/delivery_billing_status_patch.py
deleted file mode 100644
index ca022f3..0000000
--- a/patches/before_jan_2012/delivery_billing_status_patch.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-sql = webnotes.conn.sql
-
-test=1
-
-# Update SO and DN Detail 
-#--------------------------
-def update_delivered_billed_qty():
-	# update billed amt in item table in so and dn
-	sql("""	update `tabSales Order Item` so
-		set billed_amt = (select sum(amount) from `tabSales Invoice Item` where `so_detail`= so.name and docstatus=1 and parent not like 'old%%'),
-		delivered_qty = (select sum(qty) from `tabDelivery Note Item` where `prevdoc_detail_docname`= so.name and docstatus=1 and parent not like 'old%%'), 
-		modified = now()
-		where docstatus = 1
-	""")
-
-	sql(""" update `tabDelivery Note Item` dn
-		set billed_amt = (select sum(amount) from `tabSales Invoice Item` where `dn_detail`= dn.name and docstatus=1 and parent not like 'old%%'), 
-		modified = now()
-		where docstatus = 1
-	""")
-
-# update SO
-#---------------
-def update_percent():
-	# calculate % billed based on item table
-	sql("""	update `tabSales Order` so
-		set per_delivered = (select sum(if(qty > ifnull(delivered_qty, 0), delivered_qty, qty))/sum(qty)*100 from `tabSales Order Item` where parent=so.name), 
-		per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabSales Order Item` where parent = so.name), 
-		modified = now()
-		where docstatus = 1
-	""")
-		
-	# update DN	
-	# ---------	
-	sql("""	update `tabDelivery Note` dn
-		set per_billed = (select sum(if(amount > ifnull(billed_amt, 0), billed_amt, amount))/sum(amount)*100 from `tabDelivery Note Item` where parent = dn.name), 
-		modified = now()
-		where docstatus=1
-	""")
-
-# update delivery/billing status 
-#-------------------------------
-def update_status():
-	sql("""update `tabSales Order` set delivery_status = if(ifnull(per_delivered,0) < 0.001, 'Not Delivered', 
-			if(per_delivered >= 99.99, 'Fully Delivered', 'Partly Delivered'))""")
-	sql("""update `tabSales Order` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed', 
-			if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
-	sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed', 
-			if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
-			
-def execute():
-	update_delivered_billed_qty()
-	update_percent()
-	update_status()
diff --git a/patches/before_jan_2012/deploy_email_digest.py b/patches/before_jan_2012/deploy_email_digest.py
deleted file mode 100644
index 238ff00..0000000
--- a/patches/before_jan_2012/deploy_email_digest.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	"""
-		* Reload email_digest doctype
-		* Create default email digest
-	"""
-	from webnotes.modules import reload_doc
-	
-	# Minor fix in print_format doctype
-	#reload_doc('core', 'doctype', 'print_format')
-	
-	#reload_doc('setup', 'doctype', 'email_digest')
-
-	#global create_default_email_digest
-	#create_default_email_digest()
-
-	global enabled_default_email_digest
-	enabled_default_email_digest()
-
-
-def enabled_default_email_digest():
-	"""
-		Enables the created email digest
-	"""
-	from webnotes.model.doc import Document
-	from webnotes.model.code import get_obj
-	companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
-	for company in companies_list:
-		if company and company[0]:
-			edigest = Document('Email Digest', 'Default Weekly Digest - ' + company[0])
-			if edigest:
-				edigest.enabled = 1
-				edigest.save()
-				ed_obj = get_obj(doc=edigest)
-				ed_obj.on_update()
-
-
-
-def create_default_email_digest():
-	"""
-		* Weekly Digest
-		* For all companies
-		* Recipients: System Managers
-		* Full content
-		* Disabled by default
-	"""
-	from webnotes.model.doc import Document
-	companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
-	global get_system_managers
-	system_managers = get_system_managers()
-	for company in companies_list:
-		if company and company[0]:
-			edigest = Document('Email Digest')
-			edigest.name = "Default Weekly Digest - " + company[0]
-			edigest.company = company[0]
-			edigest.frequency = 'Weekly'
-			edigest.recipient_list = system_managers
-			edigest.new_leads = 1
-			edigest.new_enquiries = 1
-			edigest.new_quotations = 1
-			edigest.new_sales_orders = 1
-			edigest.new_purchase_orders = 1
-			edigest.new_transactions = 1
-			edigest.payables = 1
-			edigest.payments = 1
-			edigest.expenses_booked = 1
-			edigest.invoiced_amount = 1
-			edigest.collections = 1
-			edigest.income = 1
-			edigest.bank_balance = 1
-			exists = webnotes.conn.sql("""\
-				SELECT name FROM `tabEmail Digest`
-				WHERE name = %s""", edigest.name)
-			if (exists and exists[0]) and exists[0][0]:
-				continue
-			else:
-				edigest.save(1)
-
-
-def get_system_managers():
-	"""
-		Returns a string of system managers' email addresses separated by \n
-	"""
-	system_managers_list = webnotes.conn.sql("""\
-		SELECT DISTINCT p.name
-		FROM tabUserRole ur, tabProfile p
-		WHERE
-			ur.parent = p.name AND
-			ur.role='System Manager' AND
-			p.docstatus<2 AND
-			p.enabled=1 AND
-			p.name not in ('Administrator', 'Guest')""", as_list=1)
-
-	return "\n".join([sysman[0] for sysman in system_managers_list])
-
diff --git a/patches/before_jan_2012/edigest_enable_income_year_to_date.py b/patches/before_jan_2012/edigest_enable_income_year_to_date.py
deleted file mode 100644
index 0403e01..0000000
--- a/patches/before_jan_2012/edigest_enable_income_year_to_date.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.model.doc import Document
-
-def execute():
-	companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
-	for company in companies_list:
-		if company and company[0]:
-			edigest = Document('Email Digest', "Default Weekly Digest - " + company[0])
-			if edigest:
-				edigest.income_year_to_date = 1
-				edigest.save()
diff --git a/patches/before_jan_2012/erpnext_structure_cleanup.py b/patches/before_jan_2012/erpnext_structure_cleanup.py
deleted file mode 100644
index 6e58b18..0000000
--- a/patches/before_jan_2012/erpnext_structure_cleanup.py
+++ /dev/null
@@ -1,217 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#Cleanup all unwanted documents and restructure of moduloes
-#----------------------------------------------------------
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.model import delete_doc
-from webnotes.modules import reload_doc
-from webnotes.modules.export_file import export_to_files
-sql = webnotes.conn.sql
-
-
-#----------------------------
-
-def delete_unwanted_doctypes():
-	"deletes doctypes which are not used anymore"
-	
-	try:
-		sql("delete from `tabMenu Item`")
-		sql("delete from tabDocField where fieldname = 'site_map_details' and parent ='Control Panel'")
-	except:
-		pass
-		
-	lst = ['Zone',  'WN Account Control', 'Wiki Page', 'Wiki History', 'Wiki Control', 'While You Were Out', 'Web Visitor', 'Tweet', 'Transfer Utility', 'Transfer Module', 'Transfer Control', 'Transfer Account', 'Tips Common', 'TestTabDT', 'TestDT', 'Test Type', 'Test Run', 'Test Record Detail', 'Test Record', 'Test Case', 'Supplier TDS Category Detail', 'Shopping Cart Control', 'Service Series', 'Series Detail', 'Rule Engine', 'RFQ', 'Report Filter Detail', 'Report Field Detail','Report Control', 'Rating Widget Record', 'Rating Widget Control', 'Rating Template Detail', 'Rating Template', 'PV Ded Tax Detail', 'PV Add Tax Detail', 'Product Variant', 'Product Variance', 'Product Group', 'Product Feature', 'Payroll Tips Common', 'Payroll Rule', 'Password Control', 'Page Visit', 'Patch', 'Multiple Transfer', 'Module Tip Control', 'Module Setter', 'Module Manager', 'Module Import', 'Module Detail', 'Message Control', 'Message', 'Mail Participant Details', 'Mail', 'Leave Type Detail', 'Leave Detail', 'Leave Applicable Detail', 'Lead Item Detail', 'Lead Attachment Detail', 'Item Attachments Detail', 'Instant Message', 'Impact Analysis', 'Forum Topic', 'Forum Control', 'Form Settings', 'Follower', 'ERP Setup', 'Enquiry Attachment Detail', 'Documentation', 'Condition Detail', 'Complaint Note', 'Code History', 'Code Editor', 'Code Backup Control', 'Code Backup', 'City', 'Change Log', 'Business Letter Type', 'Business Letter Template', 'Business Letter', 'Badge Settings Detail', 'Application Type', 'Application', 'Action Detail', 'Accounts Setup', 'Stock Common', 'Job Application', 'Service Schedule', 'Comment Control', 'Bank', 'Tag Widget Control', 'Feature Update', 'RFQ Detail', 'Supplier Quotation Detail', 'Supplier Quotation', 'Year Closing Voucher', 'Approval Structure', 'Site Map Detail', 'Menu Control', 'Menu Item', 'Menu Item Role'] # bank
-	for d in lst:
-		try:
-			sql("delete from `tabProperty Setter` where select_doctype = '%s'" % d)
-			sql("delete from `tabCustom Script` where dt = '%s'" % d)
-			sql("delete from `tabCustom Field` where dt = '%s'" % d)
-			delete_doc('DocType', d)
-		except:
-			pass
-	
-		
-	sql("commit")	
-	delete_tables(lst)
-		
-def delete_tables(lst):
-	for d in lst:
-		for t in ['tab', 'arc']:
-			try:
-				sql("drop table `%s%s`" % (t, d))
-			except:
-				continue
-	
-def delete_unwanted_pages():
-	"deletes pages which are not used anymore"
-	lst = ['Transaction Authorization', 'Prduct Display', 'Data Import', 'Partner Home', 'Product Display', 'Module Settings', 'About Us', 'Custom Reports', 'MIS', 'MIS - Comparison Report', 'Monthly MIS', 'MyReports', 'Navigation Page', 'Point Race', 'Tag Widget', 'Widget Test', 'Yearly MIS']
-	for d in lst:
-		try:
-			delete_doc('Page', d)
-		except:
-			pass
-			
-			
-def delete_unwanted_search_criteria():
-	"deletes search criteria which are not used anymore"
-	
-	sql("update `tabSearch Criteria` set module = 'HR' where name = 'salary_structure_details'")
-	
-	lst = ['_SRCH00002', '_SRCH00001', 'warranty-amc_summary1', 'test_so4', 'test_so3', 'test_so2', 'test_so1', 'test_so', 'test5', 'target_variance_report1', 'STDSRCH/00006', 'STDSRCH/00005', 'STDSRCH/00004', 'STDSRCH/00003', 'STDSRCH/00002', 'STDSRCH/00001', 'so_pending_items_6', 'so_pending_items_5', 'so_pending_items_3', 'so_pending_items_34', 'scrap', 'sales_report_test', 'salary_structure_details1', 'salary_structure_details2', 'salary_structure_details3', 'salary_slips1', 'projectwise_pending_qty_and_costs2', 'projectwise_pending_qty_and_costs1', 'projectwise_delivered_qty_and_costs1', 'projectwise_delivered_qty_and_costs2', 'New Search Criteria 1', 'monthly_salary_register2', 'monthly_salary_register1', 'installed_items','follow_up_history', 'follow_up_report', 'employee_in_company_experience2', 'employee_in_company_experience1', 'employee_in_company_experience', 'employee_details', 'employee_details1', 'employee_details2', 'employees_birthday1', 'draft_so_pending_items', 'draft_sales_orders', 'delivery_notewise_pending_qty_to_install', 'datewise_leave_report2', 'datewise_leave_report1', 'datewise_leave_report', 'customer_issues1', 'cancelled_so_pending_items1', 'cancelled_so_pending_items', 'budget_variance_report3', 'budget_variance_report1', 'account_-_inputs_rg_23_a_-_part_ii_wrong_one', 'territory_item_group_wise_gp', 'sales_orderwise_pending_packing_item_summary', 'itemwise_trend', 'monthly_attendance_details_old', 'projectwise_contribution_report', 'projectwise_delivery_and_material_cost', 'projectwise_delivery_and_mat_cost_report', 'territorywise_trend', 'test_dn', 'rfq', 'rfq1']
-	
-	for d in lst:
-		if sql("select name from `tabSearch Criteria` where ifnull(standard, 'Yes') = 'Yes' and name = '%s'" % d):
-			try:
-				delete_doc('Search Criteria', d)
-			except:
-				pass
-		
-	
-def delete_unwanted_mappers():
-	"deletes unwanted mappers"
-	
-	lst = ['Customer Issue-Maintenance Report', 'Enquiry-Service Quotation', 'Sales Order-Maintenance Report', 'Service Quotation-Service Order', 'Supplier Quotation-Purchase Order', 'Visit Schedule-Maintenance Report', 'RFQ-Supplier Quotation', 'Purchase Request-RFQ']
-	for d in lst:
-		try:
-			delete_doc('DocType Mapper', d)
-		except:
-			pass	
-			
-def delete_unwanted_modules():
-	"deletes unwanted modules"
-	lst = ['Development', 'Recycle Bin', 'Testing', 'Testing System', 'Test', 'Partner Updates', 'My Company', 'Event Updates', 'E-Commerce']
-	for d in lst:
-		try:
-			delete_doc('Module Def', d)
-		except:
-			pass
-
-#---------------------------------------------	
-
-def rename_merge_modules():
-	"Rename module as per users view and merge for removing confusion"
-	
-	rename_lst = [['CRM', 'Selling'], ['SRM','Buying'], ['Material Management', 'Stock'], ['Payroll','HR'], ['Maintenance', 'Support']]
-	for d in rename_lst:
-		# create new module manually and export to file???????
-		reload_doc(d[1].lower(), 'Module Def', d[1])
-
-	merge_lst = [['Tools', 'Utilities'], ['Application Internal', 'Utilities'], ['Settings', 'Setup']]
-	# settings hardcoded in my_company
-	# module hardcoded in home_control
-	# material_management hardcoded in installation note
-	# maintenance hardcoded in support_email_settings
-	
-	lst = rename_lst + merge_lst
-	for d in lst:
-		update_module(d[0], d[1])
-		try:
-			delete_doc('Module Def', d[0])
-		except:
-			pass
-	reload_doc('Utilities', 'Module Def', 'Utilities')
-	
-def update_module(from_mod, to_mod):
-	for t in ['DocType', 'Page', 'Search Criteria', 'DocType Mapper', 'Print Format', 'Role']:
-		sql("update `tab%s` set module='%s' where module = '%s'"% (t, to_mod, from_mod))
-		
-#------------------------------------ 
-def sync_roles():
-	"Put Roles into corresponding module and delete Roles module"
-	
-	# roles
-	roles = {
-		'Accounts'	:		"'Accounts Manager', 'Accounts User', 'Auditor'", 
-		'Selling'	: 		"'Customer', 'Sales User', 'Sales Manager', 'Sales Master Manager', 'Partner'", 
-		'Buying'	:		"'Supplier', 'Purchase User', 'Purchase Manager', 'Purchase Master Manager'", 
-		'Stock'		:		"'Material User', 'Material Master Manager', 'Material Manager', 'Quality Manager'", 
-		'Support'	:		"'Support Team', 'Support Manager', 'Maintenance User', 'Maintenance Manager'", 
-		'Production':		"'Production User', 'Production Manager', 'Production Master Manager'", 
-		'Setup'		:		"'System Manager'", 
-		'Projects'	:		"'Projects User'", 
-		'HR'		:		"'HR User', 'HR Manager', 'Employee'",
-		'Core'		:		"'Administrator', 'All', 'Guest'"
-	}
-	for mod in roles.keys():
-		sql("update `tabRole` set module = '%s' where name in (%s)" % (mod, roles[mod]))
-		
-	sql("update `tabDocType` set module = 'Setup' where name = 'Role'")
-	try:
-	
-		delete_doc('Module Def', 'Roles')
-	except:
-		pass
-#------------------------------------ 
-def sync_mapper():
-	"Put mappers into corresponding module"
-		
-	mappers = {
-		'Accounts':		('Delivery Note-Sales Invoice', 'Project-Sales Invoice', 'Purchase Order-Purchase Invoice', 'Purchase Receipt-Purchase Invoice', 'Sales Order-Sales Invoice'), 
-		'Selling': 		('Delivery Note-Installation Note', 'Opportunity-Quotation', 'Lead-Opportunity', 'Lead-Customer', 'Project-Sales Order', 'Quotation-Sales Order', ), 
-		'Buying':		('Purchase Request-Purchase Order', 'Sales Order-Purchase Request'), 
-		'Stock':		('Purchase Order-Purchase Receipt', 'Project-Delivery Note', 'Sales Invoice-Delivery Note', 'Sales Order-Delivery Note'), 
-		'Support':		('Customer Issue-Maintenance Visit', 'Sales Order-Maintenance Schedule', 'Sales Order-Maintenance Visit'), 
-		'Production':	('Production Forecast-Production Plan', 'Production Forecast-Production Planning Tool', 'Sales Order-Production Plan'), 
-		'HR':			('Appraisal Template-Appraisal', 'Salary Structure-Salary Slip')
-	}
-	
-	for mod in mappers.keys():
-		sql("update `tabDocType Mapper` set module = '%s' where name in %s" % (mod, mappers[mod]))
-	try:
-		delete_doc('Module Def', 'Mapper')
-	except:
-		pass
-# --------------------------------------
-# function below will be run only in localhost
-'''def export_docs():
-	"""
-		Export all documents where module has been changed
-	"""
-	for dtype in ['DocType', 'Page', 'Search Criteria', 'DocType Mapper', 'Print Format', 'Role']:
-		lst = sql("select name, module from `tab%s`" % dtype)
-		for rec in lst:
-			webnotes.msgprint(rec)
-			if rec and rec[0] and rec[1]:
-				export_to_files(record_list = [[dtype, rec[0]]], record_module = rec[1])
-
-	#grep test company
-'''
-
-#---------------------------------------
-def run_patches():
-	# update module
-	dt_module = {'Landed Cost Purchase Receipt':'Stock', 'Landed Cost Item':'Stock', 'Comment': 'Core', 'Tag':'Core', 'Tag Detail': 'Core', 'POS Settings': 'Accounts', 'Menu Item': 'Setup', 'Menu Item Role': 'Setup'}
-	for d in dt_module.keys():
-		sql("update `tabDocType` set module = '%s' where name = '%s'" % (dt_module[d], d))
-	delete_unwanted_mappers()
-	delete_unwanted_doctypes()
-	sql("start transaction")
-	delete_unwanted_pages()
-
-	delete_unwanted_search_criteria()
-
-	
-	rename_merge_modules()
-	sync_roles()
-	sync_mapper()
-	delete_unwanted_modules()
-	# landed cost wizard link in stock
-	reload_doc('stock', 'Module Def', 'Stock')
-	
-	sql("commit")
diff --git a/patches/before_jan_2012/index_patch.py b/patches/before_jan_2012/index_patch.py
deleted file mode 100644
index 7971fbf..0000000
--- a/patches/before_jan_2012/index_patch.py
+++ /dev/null
@@ -1,311 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-"""
-	This patch removes wrong indexs and add proper indexes in tables
-"""
-
-import webnotes
-sql = webnotes.conn.sql
-from webnotes.utils import cstr
-
-def create_proper_index():
-	from webnotes.modules.export_file import export_to_files
-
-	dt_index_fields={
-						'Purchase Receipt Item': ['prevdoc_docname', 'item_code', 'warehouse', 'prevdoc_detail_docname'], 
-						'Period Closing Voucher': ['closing_account_head', 'fiscal_year'], 
-						'Lead': ['lead_name', 'status', 'transaction_date'], 
-						'Time Sheet Detail': ['app_name'], 
-						'Item Quality Inspection Parameter': [], 
-						'Budget Detail': ['fiscal_year', 'account'], 
-						'Grade': [], 
-						'Sales Taxes and Charges': ['parenttype', 'account_head'], 
-						'TDS Category Account': ['account_head'], 
-						'Role': [], 
-						'Leave Allocation': ['leave_type', 'employee', 'fiscal_year'], 
-						'Branch': [], 
-						'Department': [], 
-						'Contact Detail': [], 
-						'Territory': ['lft', 'rgt', 'parent_territory'], 
-						'Item Tax': ['tax_type'], 
-						'Bin': ['warehouse', 'item_code'], 
-						'PPW Detail': ['warehouse'], 
-						'Sales Partner': ['partner_name'], 
-						'Default Home Page': ['home_page', 'role'], 
-						'Custom Field': ['dt'], 
-						'DocFormat': ['format'], 
-						'DocType Mapper': ['from_doctype', 'to_doctype'], 
-						'Brand': [], 
-						'Quotation Lost Reason': [], 
-						'Journal Voucher': ['posting_date', 'voucher_type'], 
-						'TDS Return Acknowledgement': ['date_of_receipt', 'acknowledgement'], 
-						'BOM Report Detail': ['item_code'], 
-						'Quotation Item': ['item_code'], 
-						'Update Delivery Date Detail': ['sales_order_no'], 
-						'Sales Invoice Advance': ['journal_voucher'], 
-						'Authorization Rule': ['approving_user', 'system_user', 'system_role', 'approving_role'], 
-						'DocPerm': ['permlevel', 'role'], 
-						'Stock Entry Detail': ['item_code', 't_warehouse', 's_warehouse'], 
-						'Stock Entry': ['posting_date', 'delivery_note_no', 'purchase_receipt_no', 'production_order'], 
-						'Price List': [], 
-						'Appraisal Template Goal': [], 
-						'Production Order': ['status', 'project_name', 'production_item'], 
-						'Account': ['lft', 'rgt', 'parent_account'], 
-						'Earn Deduction Detail': [], 
-						'Purchase Request': ['status', 'transaction_date'], 
-						'Tag Detail': [], 
-						'Salary Slip Deduction': ['d_type'], 
-						'Batch': ['item'], 
-						'Deduction Type': [], 
-						'Project': ['project_name', 'customer'], 
-						'UserRole': ['role'], 
-						'DocField': ['label', 'fieldtype', 'fieldname'], 
-						'Property Setter': ['doc_type', 'doc_name', 'property'], 
-						'Appraisal': ['status', 'employee'], 
-						'Letter Head': [], 
-						'Communication Log': ['follow_up_by'], 
-						'Project Cost Breakup': [], 
-						'Table Mapper Detail': [], 
-						'Campaign': [], 
-						'SMS Parameter': [], 
-						'Leave Type': [], 
-						'Absent Days Detail': [], 
-						'Tag': [], 
-						'Raw Materials Supplied': ['raw_material'], 
-						'Project Activity Update': [], 
-						'Purchase Receipt Item Supplied': [], 
-						'Bank Reconciliation Detail': ['voucher_id'], 
-						'Sales Order': ['quotation_no', 'project_name', 'customer', 'posting_date'], 
-						'Chapter VI A Detail': [], 
-						'Employee Internal Work History': [], 
-						'Order Reconciliation Detail': ['sales_order_no'], 
-						'Attendance': ['employee', 'att_date'], 
-						'Employee External Work History': [], 
-						'Salary Structure Earning': ['e_type'], 
-						'Sales Order Item': ['item_code', 'prevdoc_docname', 'reserved_warehouse'], 
-						'Appraisal Template': [], 
-						'Budget Distribution': ['fiscal_year'], 
-						'Workstation': ['warehouse'], 
-						'Training Session Details': [], 
-						'Sales Taxes and Charges Master': [], 
-						'State': [], 
-						'Bulk Rename Tool': [], 
-						'Landed Cost Master Detail': [], 
-						'Employee': ['employee_name', 'designation', 'department'], 
-						'Terms And Conditions': [], 
-						'TC Detail': [], 
-						'UOM': [], 
-						'Supplier Type': [], 
-						'Project Milestone': [], 
-						'Landed Cost Master': [], 
-						'Budget Distribution Detail': [], 
-						'Form 16A Ack Detail': [], 
-						'Campaign Expense': [], 
-						'Time Sheet': ['employee_name', 'time_sheet_date'], 
-						'File Group': ['parent_group'], 
-						'Maintenance Visit Purpose': ['item_code', 'service_person'], 
-						'Support Ticket Response': [], 
-						'Purchase Invoice Item': ['item_code', 'purchase_order', 'po_detail', 'purchase_receipt', 'pr_detail', 'expense_head', 'cost_center'], 
-						'Timesheet Detail': ['project_name', 'task_id', 'customer_name'], 
-						'Holiday': [], 
-						'Workflow Rule Detail': [], 
-						'Module Def': ['module_seq', 'module_page'], 
-						'Terms and Conditions': [], 
-						'PF Detail': ['item_code'], 
-						'POS Setting': ['user', 'territory'], 
-						'Quality Inspection Reading': [], 
-						'Support Ticket': ['customer', 'allocated_to', 'status'], 
-						'Project Activity': ['project'], 
-						'Customer Group': ['lft', 'rgt', 'parent_customer_group'], 
-						'Sales and Purchase Return Item': ['item_code'], 
-						'Series Detail': [], 
-						'Event Role': ['role'], 
-						'Contact': ['employee_id'], 
-						'BOM Item': ['item_code', 'bom_no'], 
-						'Invest 80 Declaration Detail': [], 
-						'Purchase Order Item Supplied': [], 
-						'Industry Type': [], 
-						'Declaration Detail': [], 
-						'Holiday List': ['fiscal_year'], 
-						'Sales Person': ['lft', 'rgt', 'parent_sales_person'], 
-						'Sales Invoice Item': ['item_code', 'sales_order', 'so_detail', 'delivery_note', 'dn_detail', 'cost_center', 'income_account'], 
-						'Module Def Item': [], 
-						'TDS Category': [], 
-						'DocTrigger': [], 
-						'Print Format': ['standard'], 
-						'Installation Note Item': ['prevdoc_docname', 'item_code'], 
-						'Form 16A Tax Detail': [], 
-						'Event': ['event_date', 'event_type'], 
-						'Currency': [], 
-						'Warehouse Type': ['warehouse_type'], 
-						'Sales BOM': ['item_group'], 
-						'IT Checklist': ['employee'], 
-						'Purchase Taxes and Charges Master': [], 
-						'Company': [], 
-						'Call Log': [], 
-						'Employee Training': [], 
-						'Warehouse': ['warehouse_type'], 
-						'Competitor': [], 
-						'Mode of Payment': [], 
-						'Training Session': ['customer'], 
-						'Cost Center': ['lft', 'rgt', 'parent_cost_center'], 
-						'Timesheet': ['status', 'timesheet_date'], 
-						'Form 16A': ['party_no'], 
-						'Sales BOM Item': ['item_code'], 
-						'Answer': ['question'], 
-						'Supplier': [], 
-						'Installation Note': ['delivery_note_no', 'customer', 'inst_date'], 
-						'Expense Claim': ['approval_status', 'employee'], 
-						'Target Detail': ['from_date', 'to_date', 'fiscal_year'], 
-						'Page Role': ['role'], 
-						'Partner Target Detail': ['fiscal_year', 'item_group'], 
-						'Shipping Address': ['customer'], 
-						'Purchase Request Item': ['item_code', 'warehouse'], 
-						'TDS Payment Detail': [], 
-						'Market Segment': [], 
-						'Comment': [], 
-						'Service Order Detail': ['item_code', 'prevdoc_docname'], 
-						'TDS Payment': ['from_date', 'to_date', 'tds_category'], 
-						'Lead Email CC Detail': [], 
-						'User Setting-Role User': [], 
-						'Salary Slip': ['month', 'year', 'employee'], 
-						'Maintenance Schedule Detail': ['item_code', 'scheduled_date'], 
-						'Employment Type': [], 
-						'Purchase Invoice Advance': ['journal_voucher'], 
-						'Quotation': ['customer', 'transaction_date'], 
-						'Salary Structure Deduction': ['d_type'], 
-						'BOM': ['item', 'project_name'], 
-						'Earning Type': [], 
-						'Designation': [], 
-						'BOM Replace Utility Detail': ['parent_bom'], 
-						'Question': [], 
-						'Stock Ledger Entry': ['item_code', 'warehouse', 'posting_date', 'posting_time'], 
-						'Employee Education': [], 
-						'BOM Operation': [], 
-						'Item Group': ['lft', 'rgt', 'parent_item_group'], 
-						'Workflow Action Detail': [], 
-						'User Setting-Profile': [], 
-						'Customer Issue': ['item_code', 'customer', 'complaint_date'], 
-						'Feed': [], 
-						'Purchase Taxes and Charges': ['account_head'], 
-						'GL Mapper Detail': [], 
-						'TDS Detail': [], 
-						'PRO Detail': ['item_code', 'source_warehouse'], 
-						'DocType Label': [], 
-						'Sales Invoice': ['posting_date', 'debit_to', 'project_name'], 
-						'GL Entry': ['posting_date', 'account', 'voucher_no'], 
-						'Serial No': ['status', 'warehouse'], 
-						'Delivery Note': ['posting_date', 'project_name', 'customer'], 
-						'UOM Conversion Detail': ['uom'], 
-						'Search Criteria': ['criteria_name'], 
-						'Salary Structure': [], 
-						'Educational Qualifications': ['qualification'], 
-						'TDS Rate Chart': ['applicable_from', 'applicable_to'], 
-						'GL Mapper': [], 
-						'Announcement': [], 
-						'Call Log Details': [], 
-						'Opportunity': ['lead', 'customer', 'transaction_date'], 
-						'BOM Explosion Item': ['item_code'], 
-						'Landed Cost Item': ['account_head'], 
-						'Field Mapper Detail': ['from_field', 'to_field'], 
-						'File Data': [], 
-						'Question Tag': [], 
-						'Quality Inspection': ['item_code', 'purchase_receipt_no', 'report_date'], 
-						'Appraisal Goal': [], 
-						'POS Settings': ['territory'], 
-						'Delivery Note Item': ['item_code', 'prevdoc_docname', 'warehouse', 'prevdoc_detail_docname'], 
-						'Profile': [], 
-						'Other Income Detail': [], 
-						'Product': ['item_code', 'stock_warehouse'], 
-						'Purchase Order Item': ['prevdoc_docname', 'item_code', 'prevdoc_detail_docname', 'warehouse'], 
-						'Module Def Role': ['role'], 
-						'Sales Team': ['sales_person'], 
-						'Opportunity Item': ['item_code'], 
-						'DocType': [], 
-						'Compaint Note': ['nature_of_complaint', 'compliance_date'], 
-						'Maintenance Schedule': ['customer', 'sales_order_no'], 
-						'Event User': ['person'], 
-						'Stock Reconciliation': ['reconciliation_date'], 
-						'Purchase Receipt': ['posting_date', 'supplier', 'project_name'], 
-						'Complaint Detail': ['item_name'], 
-						'Address': ['customer', 'supplier'], 
-						'Task': ['request_date', 'allocated_to', 'category', 'customer', 'project'], 
-						'Territory Target Detail': ['month', 'fiscal_year'], 
-						'Landed Cost Purchase Receipt': ['purchase_receipt_no'], 
-						'Customer': ['customer_name', 'customer_group'], 
-						'Production Plan Sales Order': [], 
-						'Production Plan Item': ['document_date', 'item_code', 'parent_item'], 
-						'User Setting-Role Permission': [], 
-						'Custom Script': ['dt'], 
-						'Country': [], 
-						'DefaultValue': [], 
-						'Multi Ledger Report Detail': [], 
-						'Salary Slip Earning': ['e_type'], 
-						'SMS Log': [], 
-						'Expense Claim Type': [], 
-						'Item': ['item_group'], 
-						'Fiscal Year': [], 
-						'ToDo': ['role'], 
-						'Purchase Invoice': ['posting_date', 'credit_to', 'project_name', 'supplier'], 
-						'Journal Voucher Detail': ['account', 'against_voucher', 'against_invoice', 'against_jv'], 
-						'Online Contact': [], 
-						'Page': ['module'], 
-						'Leave Application': ['employee', 'leave_type', 'from_date', 'to_date'], 
-						'Expense Claim Detail': ['expense_type'], 
-						'Maintenance Visit': ['customer', 'sales_order_no', 'customer_issue_no'], 
-						'Item Price': ['price_list_name', 'ref_currency'], 
-						'SMS Receiver': [], 
-						'Naming Series Options': ['doc_type'], 
-						'Activity Type': [], 
-						'Delivery Note Packing Item': ['item_code', 'parent_item', 'warehouse'], 
-						'Workflow Rule': ['select_form'], 
-						'File': ['file_group'], 
-						'Maintenance Schedule Item': ['item_code', 'start_date', 'end_date', 'prevdoc_docname'], 
-						'Purchase Order': ['supplier', 'project_name', 'posting_date'], 
-						'Print Heading': [], 
-						'TDS Rate Detail': ['category']
-					}
-	#sql("commit") # only required if run from login
-	exist_dt = [cstr(d[0]) for d in sql("select name from `tabDocType`")]
-	
-	for dt in [d for d in dt_index_fields.keys() if d in exist_dt]:
-		try:
-			current_index = sql("show indexes from `tab%s`" % dt)
-	
-			proper_index = dt_index_fields[dt]
-	
-			for d in current_index:
-				if d[4] not in ['name', 'parent', 'parenttype']:
-					if d[4] not in proper_index:
-						sql("ALTER TABLE `tab%s` DROP INDEX %s" % (dt, d[4]))
-						sql("start transaction")
-						sql("UPDATE `tabDocField` SET search_index = 0 WHERE fieldname = '%s' AND parent = '%s'" % (d[4], dt))
-						sql("commit")
-					else:
-						proper_index.remove(d[4])
-	
-			for d in proper_index:
-				sql("ALTER TABLE `tab%s` ADD INDEX ( `%s` ) " % (dt, d))
-				sql("start transaction")
-				sql("UPDATE `tabDocField` SET search_index = 1 WHERE fieldname = '%s' AND parent = '%s'" % (d, dt))
-				sql("commit")
-		except:
-			continue
-			
-def execute():
-	create_proper_index()	
diff --git a/patches/before_jan_2012/install_print_formats.py b/patches/before_jan_2012/install_print_formats.py
deleted file mode 100644
index d3d8789..0000000
--- a/patches/before_jan_2012/install_print_formats.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import os, sys
-import webnotes
-
-path_to_file = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + ['print_formats'])
-
-def prepare_pf_dict(args_list):
-	"""
-
-	"""
-	pf_list = []
-	for a in args_list:
-		for pf_type in ['Classic', 'Modern', 'Spartan']:
-			pf = {}
-			pf['name'] = " ".join([a['name'], pf_type])
-			pf['file'] = os.sep.join([path_to_file, "".join(pf['name'].split(" ")) + ".html"])
-			pf['module'] = a['module']
-			pf['doc_type'] = a['doc_type']
-			pf['standard'] = 'Yes'
-			pf_list += [pf]
-	return pf_list
-
-
-pf_to_install = prepare_pf_dict([
-	{
-		'name' : 'Sales Invoice',
-		'doc_type' : 'Sales Invoice',
-		'module' : 'Accounts'
-	},
-	{
-		'name' : 'Sales Order',
-		'doc_type' : 'Sales Order',
-		'module' : 'Selling'
-	},
-	{
-		'name' : 'Quotation',
-		'doc_type' : 'Quotation',
-		'module' : 'Selling'
-	},
-	{
-		'name' : 'Delivery Note',
-		'doc_type' : 'Delivery Note',
-		'module' : 'Stock'
-	},
-	{
-		'name' : 'Purchase Order',
-		'doc_type' : 'Purchase Order',
-		'module' : 'Buying'
-	}
-])
-
-def execute():
-	"""
-		Install print formats
-	"""
-	from webnotes.modules import reload_doc
-	reload_doc('core', 'doctype', 'print_format')
-	
-	#copy_doctype_to_pfs()
-	global pf_to_install
-	for pf in pf_to_install:
-	#	install_print_format(pf)
-	#	print "Installed PF: " + pf['name']
-		reload_doc(pf['module'], 'Print Format', pf['name'])
-
-
-def copy_doctype_to_pfs():
-	"""
-		Copy doctype to existing print formats
-	"""
-	pf_dt_list = webnotes.conn.sql("""
-		SELECT format, parent
-		FROM `tabDocFormat`""", as_list=1)
-	
-	from webnotes.model.doc import Document
-
-	for pf, dt in pf_dt_list:
-		try:
-			d = Document('Print Format', pf)
-			d.doc_type = dt
-			d.save()
-		except Exception, e:
-			print e.args
-			pass
-
-
-def install_print_format(args):
-	"""
-		Installs print format
-		args is a dict consisting of following keys:
-			* name
-			* module
-			* doctype
-			* standard = "Yes"/"No"
-			* file
-	"""
-	from webnotes.model.doc import Document
-	d = Document('Print Format')
-	d.name = args['name']
-	f = open(args['file'])
-	d.html = f.read()
-	f.close()
-	d.module = args['module']
-	d.doc_type = args['doc_type']
-	d.standard = args['standard']
-	d.save(1)
-	from webnotes.model.code import get_obj
-	obj = get_obj('Print Format', args['name'])
-	obj.on_update()
diff --git a/patches/before_jan_2012/lcw_patch.py b/patches/before_jan_2012/lcw_patch.py
deleted file mode 100644
index f5ed4c7..0000000
--- a/patches/before_jan_2012/lcw_patch.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	
-	
-	reload_doc('stock', 'doctype', 'landed_cost_wizard')
-	reload_doc('stock', 'doctype', 'lc_pr_detail')
-	
-	webnotes.conn.sql("delete from `tabDocField` where parent ='Landed Cost Purchase Receipt' and fieldname in ('purchase_receipt_no', 'include_in_landed_cost')")
diff --git a/patches/before_jan_2012/p1.py b/patches/before_jan_2012/p1.py
deleted file mode 100644
index 10df020..0000000
--- a/patches/before_jan_2012/p1.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	if not webnotes.conn.sql("select name from tabDocFormat where parent = 'Sales Invoice' and format != 'POS Invoice'"):
-		webnotes.conn.sql("update tabDocType set default_print_format = 'Standard' where name =  'Sales Invoice'")
diff --git a/patches/before_jan_2012/packing_slip.py b/patches/before_jan_2012/packing_slip.py
deleted file mode 100644
index 10ffa86..0000000
--- a/patches/before_jan_2012/packing_slip.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('stock', 'doctype', 'delivery_note_detail')
-	reload_doc('stock', 'Print Format', 'Delivery Note Packing List Wise')
-	
-	webnotes.conn.sql("delete from `tabDocField` where fieldname in ('packed_by', 'packing_checked_by', 'pack_size') and parent = 'Delivery Note'")
-	
diff --git a/patches/before_jan_2012/price_list_patch.py b/patches/before_jan_2012/price_list_patch.py
deleted file mode 100644
index 41fbd5e..0000000
--- a/patches/before_jan_2012/price_list_patch.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('accounts', 'doctype', 'receivable_voucher')
-	reload_doc('stock', 'doctype', 'delivery_note')
-	reload_doc('selling', 'doctype', 'sales_order')
-	reload_doc('selling', 'doctype', 'quotation')
-	reload_doc('setup', 'doctype', 'manage_account')
-
-
-	for d in ['Sales Invoice', 'Delivery Note', 'Sales Order', 'Quotation']:
-		webnotes.conn.sql("update `tab%s` set price_list_currency = currency, plc_conversion_rate = conversion_rate" % d)
diff --git a/patches/before_jan_2012/print_hide_price_list.py b/patches/before_jan_2012/print_hide_price_list.py
deleted file mode 100644
index 4295ab4..0000000
--- a/patches/before_jan_2012/print_hide_price_list.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocField` set print_hide = 1 where fieldname in ('price_list_currency', 'plc_conversion_rate')")
diff --git a/patches/before_jan_2012/profile_mark_not_in_create.py b/patches/before_jan_2012/profile_mark_not_in_create.py
deleted file mode 100644
index aae0694..0000000
--- a/patches/before_jan_2012/profile_mark_not_in_create.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-def execute():
-	"""
-		Mark DocType Profile as 'not_in_create'
-	"""
-	webnotes.conn.sql("""
-		UPDATE `tabDocType`
-		SET in_create=1
-		WHERE name='Profile'
-	""")
diff --git a/patches/before_jan_2012/project_patch.py b/patches/before_jan_2012/project_patch.py
deleted file mode 100644
index 735714d..0000000
--- a/patches/before_jan_2012/project_patch.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	sql = webnotes.conn.sql
-	
-	# Reload item table
-	reload_doc('accounts', 'doctype', 'pv_detail')
-	reload_doc('buying', 'doctype', 'po_detail')
-	reload_doc('stock', 'doctype', 'purchase_receipt_detail')
-	
-	# copy project value from parent to child
-	sql("update `tabPurchase Order Item` t1, `tabPurchase Order` t2 set t1.project_name = t2.project_name where t1.parent = t2.name and ifnull(t1.project_name, '') = ''")
-	sql("update `tabPurchase Invoice Item` t1, `tabPurchase Invoice` t2 set t1.project_name = t2.project_name where t1.parent = t2.name and ifnull(t1.project_name, '') = ''")
-	sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.project_name = t2.project_name where t1.parent = t2.name and ifnull(t1.project_name, '') = ''")
-	
-	# delete project from parent
-	sql("delete from `tabDocField` where fieldname = 'project_name' and parent in ('Purchase Order', 'Purchase Receipt', 'Purchase Invoice')")
-
diff --git a/patches/before_jan_2012/reload_address.py b/patches/before_jan_2012/reload_address.py
deleted file mode 100644
index 781a00b..0000000
--- a/patches/before_jan_2012/reload_address.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('utilities', 'doctype', 'address')
diff --git a/patches/before_jan_2012/reload_bom.py b/patches/before_jan_2012/reload_bom.py
deleted file mode 100644
index 0492d72..0000000
--- a/patches/before_jan_2012/reload_bom.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('production', 'doctype', 'bill_of_materials')
diff --git a/patches/before_jan_2012/reload_doclayer.py b/patches/before_jan_2012/reload_doclayer.py
deleted file mode 100644
index 2da9187..0000000
--- a/patches/before_jan_2012/reload_doclayer.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-"""
-	Reload Customize Form, Customize Form Field and Print Format doctypes
-"""
-def execute():
-	from webnotes.modules import reload_doc
-	reload_doc('core', 'doctype', 'print_format')
-	reload_doc('core', 'doctype', 'doclayer')
-	reload_doc('core', 'doctype', 'doclayerfield')
-	reload_doc('accounts', 'doctype', 'gl_entry')
-	from webnotes.model.doc import Document
-	d = Document('DocType Label')
-	d.dt = "Customize Form"
-	d.dt_label = "Customize Form View"
-	d.save(1)
-	from webnotes.sessions import clear
-	clear()
diff --git a/patches/before_jan_2012/reload_email_digest.py b/patches/before_jan_2012/reload_email_digest.py
deleted file mode 100644
index 8e0852c..0000000
--- a/patches/before_jan_2012/reload_email_digest.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	from webnotes.modules import reload_doc
-	reload_doc('Setup', 'DocType', 'Email Digest')
diff --git a/patches/before_jan_2012/reload_employeewise_balance_leave_report.py b/patches/before_jan_2012/reload_employeewise_balance_leave_report.py
deleted file mode 100644
index 1e8ce40..0000000
--- a/patches/before_jan_2012/reload_employeewise_balance_leave_report.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('hr', 'search_criteria', 'employeewise_balance_leave_report')
diff --git a/patches/before_jan_2012/reload_flat_bom.py b/patches/before_jan_2012/reload_flat_bom.py
deleted file mode 100644
index 7c648ff..0000000
--- a/patches/before_jan_2012/reload_flat_bom.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	from webnotes.modules import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('production', 'doctype', 'flat_bom_detail')
-	reload_doc('production', 'doctype', 'bom_material')
diff --git a/patches/before_jan_2012/reload_gl_mapper.py b/patches/before_jan_2012/reload_gl_mapper.py
deleted file mode 100644
index cf67c5c..0000000
--- a/patches/before_jan_2012/reload_gl_mapper.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	
-	# reload jv gl mapper
-	reload_doc('accounts', 'GL Mapper', 'Journal Voucher')
diff --git a/patches/before_jan_2012/reload_lc_wizard.py b/patches/before_jan_2012/reload_lc_wizard.py
deleted file mode 100644
index 3de71da..0000000
--- a/patches/before_jan_2012/reload_lc_wizard.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	from webnotes.model import delete_doc
-
-	delete_doc('DocType', 'Landed Cost Wizard')
-	delete_doc('DocType', 'Landed Cost Purchase Receipt')
-	reload_doc('stock', 'doctype', 'landed_cost_wizard')
-	reload_doc('stock', 'doctype', 'lc_pr_detail')
diff --git a/patches/before_jan_2012/reload_print_format.py b/patches/before_jan_2012/reload_print_format.py
deleted file mode 100644
index d775c0c..0000000
--- a/patches/before_jan_2012/reload_print_format.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	from webnotes.model.doc import addchild
-	from webnotes.model.code import get_obj
-	reload_doc('stock', 'Print Format', 'Delivery Note Packing List Wise')
-	reload_doc('stock', 'Print Format', 'Purchase Receipt Format')
-	reload_doc('accounts', 'Print Format', 'Payment Receipt Voucher')
-	reload_doc('accounts', 'Print Format', 'POS Invoice')
-	reload_doc('accounts', 'Print Format', 'Form 16A Print Format')
-	reload_doc('accounts', 'Print Format', 'Cheque Printing Format')
-	
-	if not webnotes.conn.sql("select format from `tabDocFormat` where name = 'POS Invoice' and parent = 'Sales Invoice'"):		
-		dt_obj = get_obj('DocType', 'Sales Invoice', with_children = 1)
-		ch = addchild(dt_obj.doc, 'formats', 'DocFormat', 1)
-		ch.format = 'POS Invoice'
-		ch.save(1)
diff --git a/patches/before_jan_2012/reload_project_task.py b/patches/before_jan_2012/reload_project_task.py
deleted file mode 100644
index c6b38d5..0000000
--- a/patches/before_jan_2012/reload_project_task.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-"""
-	Reload Task Doctype of Project Module
-"""
-def execute():
-	from webnotes.modules import reload_doc
-	reload_doc('Projects', 'DocType', 'Task')
-
diff --git a/patches/before_jan_2012/reload_reco.py b/patches/before_jan_2012/reload_reco.py
deleted file mode 100644
index 2c303c5..0000000
--- a/patches/before_jan_2012/reload_reco.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	
-	reload_doc('stock', 'doctype', 'stock_reconciliation')
-	webnotes.conn.sql("delete from `tabDocField` where (label in ('Validate Data', 'Attachment HTML', 'Attachment') or fieldname in ('next_step', 'company', 'fiscal_year', 'amendment_date')) and parent = 'Stock Reconciliation'")
diff --git a/patches/before_jan_2012/reload_rv.py b/patches/before_jan_2012/reload_rv.py
deleted file mode 100644
index 3c7b5be..0000000
--- a/patches/before_jan_2012/reload_rv.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	from webnotes.model.code import get_obj
-
-	reload_doc('accounts', 'doctype', 'receivable_voucher')
-
-	reload_doc('setup', 'doctype', 'features_setup')
-	get_obj('Features setup').validate()
diff --git a/patches/before_jan_2012/reload_support_ticket.py b/patches/before_jan_2012/reload_support_ticket.py
deleted file mode 100644
index 0fe611b..0000000
--- a/patches/before_jan_2012/reload_support_ticket.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('Support', 'DocType', 'Support Ticket')
-	from webnotes.model.code import get_obj
-	get_obj('DocType', 'Support Ticket').validate()
diff --git a/patches/before_jan_2012/remove_duplicate_table_mapper_detail.py b/patches/before_jan_2012/remove_duplicate_table_mapper_detail.py
deleted file mode 100644
index 3594a70..0000000
--- a/patches/before_jan_2012/remove_duplicate_table_mapper_detail.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-"""
-	Removes duplicate entries created in 
-"""
-import webnotes
-def execute():
-	res = webnotes.conn.sql("""\
-		SELECT a.name
-		FROM
-			`tabTable Mapper Detail` a,
-			`tabTable Mapper Detail` b
-		WHERE
-			a.parent = b.parent AND
-			a.from_table = b.from_table AND
-			a.to_table = b.to_table AND
-			a.from_field = b.from_field AND
-			a.to_field = b.to_field AND
-			a.name < b.name""")
-	if res and len(res)>0:
-		name_string = ", ".join(["'" + str(r[0]) + "'" for r in res])
-		res = webnotes.conn.sql("""\
-			DELETE FROM `tabTable Mapper Detail`
-			WHERE name IN (%s)""" % name_string)
diff --git a/patches/before_jan_2012/remove_extra_button_from_email_digest.py b/patches/before_jan_2012/remove_extra_button_from_email_digest.py
deleted file mode 100644
index fa2481d..0000000
--- a/patches/before_jan_2012/remove_extra_button_from_email_digest.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("""
-		DELETE FROM tabDocField
-		WHERE parent = 'Email Digest'
-		AND label = 'Add Recipients'
-		AND fieldtype = 'Button'""")
-
diff --git a/patches/before_jan_2012/remove_old_cp_email_settings.py b/patches/before_jan_2012/remove_old_cp_email_settings.py
deleted file mode 100644
index 6417441..0000000
--- a/patches/before_jan_2012/remove_old_cp_email_settings.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		remove control panel email settings if automail.webnotestech.com
-	"""
-	from webnotes.model.doc import Document
-	cp = Document('Control Panel', 'Control Panel')
-	if cp:
-		if cp.outgoing_mail_server == 'mail.webnotestech.com':
-			cp.outgoing_mail_server = None;
-			cp.mail_login = None;
-			cp.mail_password = None;
-			cp.mail_port = None;
-			cp.auto_email_id = 'automail@erpnext.com'
-			cp.save()
-
diff --git a/patches/before_jan_2012/remove_page_break_from_defaults.py b/patches/before_jan_2012/remove_page_break_from_defaults.py
deleted file mode 100644
index 8ee441a..0000000
--- a/patches/before_jan_2012/remove_page_break_from_defaults.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("""delete from `tabDefaultValue` where defkey in ('page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos', 'purchase_discounts', 'recurring_invoice') and parent = 'Control Panel'""")
diff --git a/patches/before_jan_2012/remove_previous_field_property_setter.py b/patches/before_jan_2012/remove_previous_field_property_setter.py
deleted file mode 100644
index a993a25..0000000
--- a/patches/before_jan_2012/remove_previous_field_property_setter.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-def execute():
-	webnotes.conn.sql("""\
-		DELETE FROM `tabProperty Setter`
-		WHERE property='previous_field'
-	""")
diff --git a/patches/before_jan_2012/repost_account_bal.py b/patches/before_jan_2012/repost_account_bal.py
deleted file mode 100644
index b1d68c7..0000000
--- a/patches/before_jan_2012/repost_account_bal.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	sql = webnotes.conn.sql
-	from webnotes.model.code import get_obj
-	
-	# repost
-	comp = sql("select name from tabCompany where docstatus!=2")
-	fy = sql("select name from `tabFiscal Year` order by year_start_date asc")
-	for c in comp:
-		prev_fy = ''
-		for f in fy:
-			fy_obj = get_obj('Fiscal Year', f[0])
-			fy_obj.doc.past_year = prev_fy
-			fy_obj.doc.company = c[0]
-			fy_obj.repost()
-			prev_fy = f[0]
-			webnotes.conn.commit()
-			webnotes.conn.begin()
\ No newline at end of file
diff --git a/patches/before_jan_2012/repost_stock.py b/patches/before_jan_2012/repost_stock.py
deleted file mode 100644
index 3976eba..0000000
--- a/patches/before_jan_2012/repost_stock.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-    import webnotes
-    sql = webnotes.conn.sql
-    from webnotes.model.code import get_obj
-    from webnotes.utils import flt
-
-    # update incoming rate in serial nos
-    sr = sql("""select name, item_code, purchase_document_no from `tabSerial No`
-            where docstatus = 1 and purchase_document_type = 'Purchase Receipt'""")
-    for d in sr:
-        val_rate = sql("""select valuation_rate from `tabPurchase Receipt Item`
-            where item_code = %s and parent = %s""", (d[1], d[2]))
-        sql("""update `tabSerial No` set purchase_rate = %s where name = %s""",
-           (val_rate and flt(val_rate[0][0]) or 0, d[0]))
-    
-    
-    # repost for all serialized item
-    bin = sql("""select t1.name from `tabBin` t1, tabItem t2 where t1.item_code = t2.name and ifnull(has_serial_no, 'No') = 'Yes'""")
-    for d in bin:
-        get_obj('Bin', d[0]).update_entries_after(posting_date = '2000-01-01', posting_time = '12:00')
-        sql("commit")
-        sql("start transaction")
-
diff --git a/patches/before_jan_2012/sal_man_patch.py b/patches/before_jan_2012/sal_man_patch.py
deleted file mode 100644
index b6dd6f0..0000000
--- a/patches/before_jan_2012/sal_man_patch.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	sql = webnotes.conn.sql
-
-	reload_doc('hr', 'doctype', 'salary_manager')
-	sql("delete from `tabDocField` where parent = 'Salary Manager' and fieldname = 'employment_type'")
diff --git a/patches/before_jan_2012/task_email_notification.py b/patches/before_jan_2012/task_email_notification.py
deleted file mode 100644
index 5e8b394..0000000
--- a/patches/before_jan_2012/task_email_notification.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('projects', 'doctype', 'ticket')
diff --git a/patches/before_jan_2012/update_0_idx.py b/patches/before_jan_2012/update_0_idx.py
deleted file mode 100644
index 9a192e5..0000000
--- a/patches/before_jan_2012/update_0_idx.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-def execute():
-	doc_type_list = webnotes.conn.sql("""SELECT DISTINCT parent FROM `tabDocField` where idx=0""")
-	for doc_type in doc_type_list:
-		if doc_type and doc_type[0]:
-			webnotes.conn.sql("""\
-				UPDATE `tabDocField` SET idx=idx+1
-				WHERE parent=%s
-			""", doc_type[0])
diff --git a/patches/before_jan_2012/update_gle_against_voucher_for_jv.py b/patches/before_jan_2012/update_gle_against_voucher_for_jv.py
deleted file mode 100644
index b262778..0000000
--- a/patches/before_jan_2012/update_gle_against_voucher_for_jv.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.model.code import get_obj
-	
-	# select jv where against_jv exists
-	jv = webnotes.conn.sql("select distinct parent from `tabJournal Voucher Detail` where docstatus = 1 and ifnull(against_jv, '') != ''")
-
-	for d in jv:
-		jv_obj = get_obj('Journal Voucher', d[0], with_children=1)
-
-		# cancel
-		get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =1, adv_adj = 1)
-
-		#re-submit
-		get_obj(dt='GL Control').make_gl_entries(jv_obj.doc, jv_obj.doclist, cancel =0, adv_adj = 1)
diff --git a/patches/december_2012/production_cleanup.py b/patches/december_2012/production_cleanup.py
new file mode 100644
index 0000000..8e226bd
--- /dev/null
+++ b/patches/december_2012/production_cleanup.py
@@ -0,0 +1,30 @@
+import webnotes
+
+def execute():
+	delete_doctypes()
+	rename_module()
+	
+def delete_doctypes():
+	from webnotes.model import delete_doc
+	delete_doc("DocType", "Production Control")
+	delete_doc("DocType", "BOM Control")
+	
+def rename_module():
+	webnotes.reload_doc("core", "doctype", "role")
+	webnotes.reload_doc("core", "doctype", "page")
+	webnotes.reload_doc("core", "doctype", "module_def")
+
+	webnotes.rename_doc("Role", "Production User", "Manufacturing User")
+	webnotes.rename_doc("Role", "Production Manager", "Manufacturing Manager")
+
+	if webnotes.conn.exists("Page", "manufacturing-home"):
+		webnotes.delete_doc("Page", "production-home")
+	else:
+		webnotes.rename_doc("Page", "production-home", "manufacturing-home")
+
+	webnotes.rename_doc("Module Def", "Production", "Manufacturing")
+	
+	webnotes.conn.set_global("modules_list",
+		webnotes.conn.get_global('modules_list').replace("Production", "Manufacturing"))
+	
+	
\ No newline at end of file
diff --git a/patches/jan_mar_2012/__init__.py b/patches/jan_mar_2012/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/patches/jan_mar_2012/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/patches/jan_mar_2012/account_type_patch.py b/patches/jan_mar_2012/account_type_patch.py
deleted file mode 100644
index c6ac05c..0000000
--- a/patches/jan_mar_2012/account_type_patch.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("""update `tabAccount` 
-		set account_type = 'Chargeable' 
-		where account_name in ('CENVAT Capital Goods', 'CENVAT Service Tax', 'CENVAT Service Tax Cess 1', 'CENVAT Service Tax Cess 2', 
-			'P L A', 'P L A - Cess Portion', 'VAT', 'TDS (Advertisement)', 'TDS (Commission)', 'TDS (Contractor)', 'TDS (Interest)', 
-			'TDS (Rent)', 'TDS (Salary)')
-	""")
-
diff --git a/patches/jan_mar_2012/add_roles_to_admin.py b/patches/jan_mar_2012/add_roles_to_admin.py
deleted file mode 100644
index f2e91e9..0000000
--- a/patches/jan_mar_2012/add_roles_to_admin.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	"""
-		Adds various roles to Administrator. This patch is for making master db
-		ready for on premise installation
-	"""
-	import webnotes
-	from webnotes.model.code import get_obj
-	from webnotes.model.doc import Document
-	sc = get_obj('Setup Control', 'Setup Control')
-	sc.add_roles(Document('Profile', 'Administrator'))
diff --git a/patches/jan_mar_2012/allocated_to_profile.py b/patches/jan_mar_2012/allocated_to_profile.py
deleted file mode 100644
index b38f97b..0000000
--- a/patches/jan_mar_2012/allocated_to_profile.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		Changes allocated_to option to Profile in
-		DocType Customer Issue
-	"""
-	import webnotes
-	webnotes.conn.sql("""
-		UPDATE `tabDocField`
-		SET options='Profile'
-		WHERE fieldname='allocated_to'
-	""")
-
-	webnotes.conn.sql("""
-		DELETE from `tabDocField`
-		WHERE parent='Customer Issue'
-		AND label='Make Maintenance Visit'
-	""")
-
-	from webnotes.modules import reload_doc
-	reload_doc('support', 'doctype', 'customer_issue')
diff --git a/patches/jan_mar_2012/apps/__init__.py b/patches/jan_mar_2012/apps/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/patches/jan_mar_2012/apps/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/patches/jan_mar_2012/apps/todo_item.py b/patches/jan_mar_2012/apps/todo_item.py
deleted file mode 100644
index ed0acc4..0000000
--- a/patches/jan_mar_2012/apps/todo_item.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		* Reload ToDo
-	"""
-	from webnotes.modules import reload_doc
-	reload_doc('utilities', 'doctype', 'todo_item')
diff --git a/patches/jan_mar_2012/cancel_purchase_returned.py b/patches/jan_mar_2012/cancel_purchase_returned.py
deleted file mode 100644
index ff287c5..0000000
--- a/patches/jan_mar_2012/cancel_purchase_returned.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		Set docstatus = 2 where status = 'Purchase Returned' for serial no
-	"""
-	import webnotes
-	webnotes.conn.sql("""\
-		UPDATE `tabSerial No` SET docstatus=2
-		WHERE status='Purchase Returned'""")
diff --git a/patches/jan_mar_2012/clear_session_cache.py b/patches/jan_mar_2012/clear_session_cache.py
deleted file mode 100644
index 0490f50..0000000
--- a/patches/jan_mar_2012/clear_session_cache.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.clear_cache()
diff --git a/patches/jan_mar_2012/convert_tables_to_utf8.py b/patches/jan_mar_2012/convert_tables_to_utf8.py
deleted file mode 100644
index 9378aba..0000000
--- a/patches/jan_mar_2012/convert_tables_to_utf8.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	sql = webnotes.conn.sql
-	
-	sql("commit")
-	sql("set foreign_key_checks=0")
-	for tab in sql("show tables"):
-		sql("ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8" % tab[0])
-
-	sql("set foreign_key_checks=1")
diff --git a/patches/jan_mar_2012/customer_address_contact_patch.py b/patches/jan_mar_2012/customer_address_contact_patch.py
deleted file mode 100644
index 8a3e67a..0000000
--- a/patches/jan_mar_2012/customer_address_contact_patch.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	"""
-		* Reload Search Criteria "Customer Address Contact"
-		* SET is_primary_contact=1, is_primary_address=1 WHERE not specified
-	"""
-	reload_sc()
-	patch_primary_contact()
-	patch_primary_address()
-
-def reload_sc():
-	from webnotes.modules import reload_doc
-	reload_doc('selling', 'search_criteria', 'customer_address_contact')
-	reload_doc('selling', 'Module Def', 'Selling')
-
-def patch_primary_contact():
-	res = webnotes.conn.sql("""
-		SELECT name FROM `tabContact`
-		WHERE customer IN (
-			SELECT customer FROM `tabContact`
-			WHERE IFNULL(customer, '')!=''
-			GROUP BY customer HAVING SUM(IFNULL(is_primary_contact, 0))=0
-		) OR supplier IN (
-			SELECT supplier FROM `tabContact`
-			WHERE IFNULL(supplier, '')!=''
-			GROUP BY supplier HAVING SUM(IFNULL(is_primary_contact, 0))=0
-		) OR sales_partner IN (
-			SELECT sales_partner FROM `tabContact`
-			WHERE IFNULL(sales_partner, '')!=''
-			GROUP BY sales_partner HAVING SUM(IFNULL(is_primary_contact, 0))=0
-		)
-	""", as_list=1)
-	names = ", ".join(['"' + unicode(r[0]) + '"' for r in res if r])
-	if names: webnotes.conn.sql("UPDATE `tabContact` SET is_primary_contact=1 WHERE name IN (%s)" % names)
-
-def patch_primary_address():
-	res = webnotes.conn.sql("""
-		SELECT name FROM `tabAddress`
-		WHERE customer IN (
-			SELECT customer FROM `tabAddress`
-			WHERE IFNULL(customer, '')!=''
-			GROUP BY customer HAVING SUM(IFNULL(is_primary_address, 0))=0
-			AND SUM(IFNULL(is_shipping_address, 0))=0
-		) OR supplier IN (
-			SELECT supplier FROM `tabAddress`
-			WHERE IFNULL(supplier, '')!=''
-			GROUP BY supplier HAVING SUM(IFNULL(is_primary_address, 0))=0
-			AND SUM(IFNULL(is_shipping_address, 0))=0
-		) OR sales_partner IN (
-			SELECT sales_partner FROM `tabAddress`
-			WHERE IFNULL(sales_partner, '')!=''
-			GROUP BY sales_partner HAVING SUM(IFNULL(is_primary_address, 0))=0
-			AND SUM(IFNULL(is_shipping_address, 0))=0
-		)
-	""", as_list=1)
-	names = ", ".join(['"' + unicode(r[0]) + '"' for r in res if r])
-	if names: webnotes.conn.sql("UPDATE `tabAddress` SET is_primary_address=1 WHERE name IN (%s)" % names)
diff --git a/patches/jan_mar_2012/delete_pur_of_service.py b/patches/jan_mar_2012/delete_pur_of_service.py
deleted file mode 100644
index 18ded0d..0000000
--- a/patches/jan_mar_2012/delete_pur_of_service.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.model import delete_doc
-	delete_doc('DocType', 'Purpose of Service')
diff --git a/patches/jan_mar_2012/deploy_packing_slip.py b/patches/jan_mar_2012/deploy_packing_slip.py
deleted file mode 100644
index a6ec881..0000000
--- a/patches/jan_mar_2012/deploy_packing_slip.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.modules import reload_doc
-
-def execute():
-	delete_fields_dn_detail()
-	deploy_packing_slip()
-	del_packing_slip_pf()
-
-
-def delete_fields_dn_detail():
-	"""
-		Delete old fields related to packing slip
-	"""
-	from webnotes.model import delete_fields
-	delete_fields({
-		'Delivery Note': [
-			'print_packing_slip', 'shipping_mark', 'packed_by',
-			'packing_checked_by', 'Text', 'pack_size'
-		],
-		'Delivery Note Item': [
-			'pack_no', 'pack_gross_wt', 'weight_uom', 
-			'pack_nett_wt', 'no_of_packs', 'pack_unit', 'pack_size', 
-			'packed_by', 'packing_checked_by'
-		]
-	}, delete=1)
-	delete_fields({'Item': ['nett_weight', 'gross_weight']}, delete=1)
-	reload_doc('stock', 'doctype', 'delivery_note')
-	reload_doc('stock', 'doctype', 'delivery_note_detail')
-	reload_doc('stock', 'doctype', 'item')
-
-
-def deploy_packing_slip():
-	reload_doc('stock', 'doctype', 'packing_slip')
-	reload_doc('stock', 'doctype', 'packing_slip_detail')
-	reload_doc('stock', 'Module Def', 'Stock')
-	reload_doc('stock', 'DocType Mapper', 'Delivery Note-Packing Slip')
-
-
-def del_packing_slip_pf():
-	"""
-		Delete Print Format: 'Delivery Note Packing List Wise'
-	"""
-	webnotes.conn.sql("""\
-		DELETE FROM `tabDocFormat`
-		WHERE parent='Delivery Note'
-		AND format='Delivery Note Packing List Wise'""")
-	from webnotes.model import delete_doc
-	delete_doc('Print Format', 'Delivery Note Packing List Wise')
diff --git a/patches/jan_mar_2012/doclabel_in_doclayer.py b/patches/jan_mar_2012/doclabel_in_doclayer.py
deleted file mode 100644
index 4e6260e..0000000
--- a/patches/jan_mar_2012/doclabel_in_doclayer.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-def execute():
-	"""
-		* Change option of doclayer's doc_type field
-		* Reload doclayer
-	"""
-	webnotes.conn.sql("""
-		UPDATE `tabDocField` SET options=NULL
-		WHERE parent='Customize Form' AND fieldname='doc_type'
-	""")
-	from webnotes.modules import reload_doc
-	reload_doc('core', 'doctype', 'doclayer')
diff --git a/patches/jan_mar_2012/dt_map_fix.py b/patches/jan_mar_2012/dt_map_fix.py
deleted file mode 100644
index d682102..0000000
--- a/patches/jan_mar_2012/dt_map_fix.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	webnotes.conn.sql("delete from `tabField Mapper Detail` where from_field = 'transaction_date' and parent in ('Sales Order-Delivery Note', 'Purchase Order-Purchase Receipt')")
-
-	reload_doc('stock', 'DocType Mapper', 'Sales Order-Delivery Note')
-	reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
diff --git a/patches/jan_mar_2012/email_settings_reload.py b/patches/jan_mar_2012/email_settings_reload.py
deleted file mode 100644
index fe6b260..0000000
--- a/patches/jan_mar_2012/email_settings_reload.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		* Change type of mail_port field to int
-		* reload email settings
-	"""
-	import webnotes
-	webnotes.conn.sql("""
-		UPDATE `tabDocField` SET fieldtype='Int'
-		WHERE parent = 'Email Settings' AND fieldname = 'mail_port'
-	""")
-
-	from webnotes.modules import reload_doc
-	reload_doc('setup', 'doctype', 'email_settings')
diff --git a/patches/jan_mar_2012/fix_packing_slip.py b/patches/jan_mar_2012/fix_packing_slip.py
deleted file mode 100644
index 218d89d..0000000
--- a/patches/jan_mar_2012/fix_packing_slip.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		* Change DN to PS mapper
-			+ Set Ref doc should be submitted to 0
-			+ Set validation logic of DN PS Table mapper record to docstatus=0
-	"""
-	import webnotes
-	webnotes.conn.sql("""\
-		UPDATE `tabDocType Mapper`
-		SET ref_doc_submitted=0
-		WHERE name='Delivery Note-Packing Slip'""")
-	
-	webnotes.conn.sql("""\
-		UPDATE `tabTable Mapper Detail`
-		SET validation_logic='docstatus=0'
-		WHERE parent='Delivery Note-Packing Slip'
-		AND docstatus=0
-		AND from_table='Delivery Note'
-		AND to_table='Packing Slip'""")
-
diff --git a/patches/jan_mar_2012/jan_production_patches.py b/patches/jan_mar_2012/jan_production_patches.py
deleted file mode 100644
index 87b9205..0000000
--- a/patches/jan_mar_2012/jan_production_patches.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-def execute():
-	"""
-		Patch includes:
-		* Reload of Stock Entry Detail
-	"""
-	from webnotes.modules import reload_doc
-
-	reload_doc('stock', 'doctype', 'stock_entry_detail')
-	reload_doc('stock', 'doctype', 'item_supplier')
-	reload_doc('stock', 'doctype', 'item')
-
-	webnotes.conn.sql("""
-		UPDATE tabDocField SET fieldtype='Float'
-		WHERE parent='BOM'
-		AND fieldname IN ('operating_cost', 'raw_material_cost', 'total_cost')
-	""")
-
-	webnotes.conn.sql("""
-		UPDATE tabDocField SET fieldtype='Float'
-		WHERE parent='BOM Item'
-		AND fieldname IN ('qty', 'rate', 'amount', 'qty_consumed_per_unit')
-	""")
-	
-	reload_doc('stock', 'doctype', 'stock_entry')
-	reload_doc('production', 'doctype', 'bill_of_materials')
-	reload_doc('production', 'doctype', 'bom_material')
diff --git a/patches/jan_mar_2012/label_cleanup.py b/patches/jan_mar_2012/label_cleanup.py
deleted file mode 100644
index 4f4fc4e..0000000
--- a/patches/jan_mar_2012/label_cleanup.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.model import delete_doc
-	from webnotes.modules import reload_doc
-
-
-	webnotes.conn.sql("""delete from `tabDocField` 
-		where label in ('Note1', 'OT Notes', 'Note', 'Note HTML', 'Rates HTML') 
-		and parent in ('Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice', 'Purchase Order')""")
-
-
-	del_flds = {
-		'Sales Order Item':	"'delivery_date', 'confirmation_date'", 
-		'Delivery Note':		"'supplier', 'supplier_address', 'purchase_receipt_no', 'purchase_order_no', 'transaction_date'",
-		'Sales Invoice':	"'voucher_date'",
-		'Purchase Invoice':		"'voucher_date'",
-		'Purchase Receipt':		"'transaction_date'"
-	} 
-
-	del_labels = {
-		'Delivery Note':		"'Supplier Details'",
-		'Purchase Receipt':		"'Get Currrent Stock'"
-	}
-
-	for d in del_flds:
-		webnotes.conn.sql("delete from `tabDocField` where fieldname in (%s) and parent = '%s'"% (del_flds[d], d))
-
-	for d in del_labels:
-		webnotes.conn.sql("delete from `tabDocField` where label in (%s) and parent = '%s'"% (del_labels[d], d))
-
-	delete_doc('DocType', 'Update Delivery Date Detail')
-
-	# Reload print formats
-	reload_doc('accounts', 'Print Format', 'Sales Invoice Classic')
-	reload_doc('accounts', 'Print Format', 'Sales Invoice Modern')
-	reload_doc('accounts', 'Print Format', 'Sales Invoice Spartan')
-
diff --git a/patches/jan_mar_2012/map_conversion_rate.py b/patches/jan_mar_2012/map_conversion_rate.py
deleted file mode 100644
index 7e5e7c5..0000000
--- a/patches/jan_mar_2012/map_conversion_rate.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.model.code import get_obj
-from webnotes.model.doc import addchild
-
-def execute():
-	"""
-		* Maps conversion rate in doctype mapper PO-PR
-		* Maps conversion rate in doctype mapper PO-PV
-	"""
-	args = [
-		{
-			'parent': 'Purchase Order-Purchase Receipt',
-			'map': [{
-				'from_table': 'Purchase Order',
-				'to_table': 'Purchase Receipt',
-				'fields': [['conversion_rate', 'conversion_rate', 'Yes']]
-			}]
-		},
-		{
-			'parent': 'Purchase Order-Purchase Invoice',
-			'map': [{
-				'from_table': 'Purchase Order',
-				'to_table': 'Purchase Invoice',
-				'fields': [['conversion_rate', 'conversion_rate', 'Yes']]
-			}]
-		},
-	]
-
-	for a in args:
-		for m in a['map']:
-			match_id = webnotes.conn.sql("""\
-				SELECT match_id FROM `tabTable Mapper Detail`
-				WHERE parent=%s AND from_table=%s AND to_table=%s\
-				""", (a['parent'], m['from_table'], m['to_table']))[0][0]
-			for f in m['fields']:
-				res = webnotes.conn.sql("""\
-					SELECT name FROM `tabField Mapper Detail`
-					WHERE parent=%s AND from_field=%s AND to_field=%s
-					AND match_id=%s""", (a['parent'], f[0], f[1], match_id))
-				if not res:
-					max_idx = webnotes.conn.sql("""\
-						SELECT IFNULL(MAX(idx), 0) FROM `tabField Mapper Detail`
-						WHERE parent=%s""", a['parent'])[0][0]
-					obj = get_obj('DocType Mapper', a['parent'])
-					c = addchild(obj.doc, 'field_mapper_details', 'Field Mapper Detail', obj.doclist)
-					c.from_field = f[0]
-					c.to_field = f[1]
-					c.fields['map'] = f[2]
-					c.match_id = match_id
-					c.idx = max_idx + 1
-					c.save()
diff --git a/patches/jan_mar_2012/mapper_fix.py b/patches/jan_mar_2012/mapper_fix.py
deleted file mode 100644
index e8e68e0..0000000
--- a/patches/jan_mar_2012/mapper_fix.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("delete from `tabTable Mapper Detail` where to_table = 'Sales Invoice Item' and parent = 'Delivery Note-Sales Invoice' and validation_logic = 'amount > ifnull(billed_amt, 0) and docstatus = 1'")
diff --git a/patches/jan_mar_2012/navupdate.py b/patches/jan_mar_2012/navupdate.py
deleted file mode 100644
index a99f924..0000000
--- a/patches/jan_mar_2012/navupdate.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-import _mysql_exceptions
-
-def execute():
-	from webnotes.modules import reload_doc
-	reload_doc('accounts', 'page', 'accounts_home')
-	reload_doc('selling', 'page', 'selling_home')
-	reload_doc('buying', 'page', 'buying_home')
-	reload_doc('stock', 'page', 'stock_home')
-	reload_doc('hr', 'page', 'hr_home')
-	reload_doc('support', 'page', 'support_home')
-	reload_doc('production', 'page', 'production_home')
-	reload_doc('projects', 'page', 'projects_home')
-	reload_doc('website', 'page', 'website_home')
-	reload_doc('home', 'page', 'desktop')
-	reload_doc('utilities', 'page', 'todo')
-	reload_doc('utilities', 'page', 'calendar')
-	reload_doc('utilities', 'page', 'messages')
-	reload_doc('setup', 'page', 'modules_setup')
-	reload_doc('utilities', 'page', 'users')
-	reload_doc('home', 'page', 'activity')
-	reload_doc('home', 'page', 'attributions')
-	reload_doc('core', 'doctype', 'profile')
-	
-	# update user_image in profile
-	for p in webnotes.conn.sql("""select name, file_list from tabProfile 
-		where ifnull(file_list,'')!=''"""):
-		fid = p[1].split('\n')[0].split(',')[1]
-		webnotes.conn.set_value('Profile', p[0], 'user_image', fid)
-	
-	webnotes.conn.set_value('Control Panel', 'Control Panel', 'home_page',
-			'desktop')
-
-	webnotes.conn.commit()
-
-	try:
-		webnotes.conn.sql("""create table __SchedulerLog (
-			`timestamp` timestamp,
-			method varchar(200),
-			error text
-		) engine=MyISAM""")
-	except _mysql_exceptions.OperationalError, e:
-		pass
diff --git a/patches/jan_mar_2012/no_copy_patch.py b/patches/jan_mar_2012/no_copy_patch.py
deleted file mode 100644
index c7d33cb..0000000
--- a/patches/jan_mar_2012/no_copy_patch.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocField` set no_copy = 1 where fieldname = 'insert_after' and parent = 'Custom Field'")
diff --git a/patches/jan_mar_2012/pending_patches.py b/patches/jan_mar_2012/pending_patches.py
deleted file mode 100644
index f98b13f..0000000
--- a/patches/jan_mar_2012/pending_patches.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.model.code import get_obj
-	from webnotes.modules import reload_doc
-	sql = webnotes.conn.sql
-
-	reload_doc('hr', 'doctype', 'appraisal')
-
-	sql("update `tabDocField` set `hidden` = 0 where fieldname = 'group_or_ledger' and parent = 'Cost Center'")
-	sql("update tabDocPerm set amend = 0 where parent = 'Salary Structure'")
-	sql("update tabDocPerm set cancel = 1 where parent = 'Company' and role = 'System Manager'")
-	
-	if sql("select count(name) from `tabDocField` where label = 'View Ledger Entry' and parent = 'Journal Voucher' and fieldtype = 'Button'")[0][0] > 1:
-		sql("delete from `tabDocField` where label = 'View Ledger Entry' and parent = 'Journal Voucher' and fieldtype = 'Button' limit 1")
-	if sql("select count(name) from `tabDocField` where label = 'Get Balance' and parent = 'Journal Voucher' and fieldtype = 'Button'")[0][0] > 1:
-		sql("delete from `tabDocField` where label = 'Get Balance' and parent = 'Journal Voucher' and fieldtype = 'Button' limit 1")
-			
-		
-	if sql("select count(name) from `tabDocField` where label = 'Get Specification Details' and parent = 'Quality Inspection' and fieldtype = 'Button'")[0][0] > 1:
-		sql("delete from `tabDocField` where label = 'Get Specification Details' and parent = 'Quality Inspection' and fieldtype = 'Button' limit 1")
-	
-	reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
-		
-	reload_doc('accounts', 'doctype', 'cost_center')
-	sql("update `tabDocType` set subject = 'Item Code: %(item_code)s, Warehouse: %(warehouse)s' where name = 'Serial No'")
-
-	# Patch for adding packing related columns (packed by, checked by, shipping mark etc)
-	reload_doc('stock','doctype','delivery_note')
-	sql("update `tabDocField` set allow_on_submit = 1 where fieldname = 'page_break'")
-	sql("update `tabDocField` set allow_on_submit = 1 where fieldname in ('indent_details', 'po_details', 'purchase_receipt_details', 'entries', 'sales_order_details', 'delivery_note_details', 'quotation_details') and fieldtype = 'Table'")
-		
-	from webnotes.sessions import clear_cache
-	clear_cache(webnotes.session['user'])
-
-	# FEATURES SETUP
-	#----------------
-	reload_doc('setup', 'doctype','features_setup')
-	flds = ['page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos']
-	st = "'"+"', '".join(flds)+"'"
-	sql("delete from `tabSingles` where field in (%s) and doctype = 'Features Setup'" % st)
-	sql("delete from `tabDocField` where fieldname in (%s) and parent = 'Features Setup'" % st)
-	sql("delete from `tabDefaultValue` where defkey in (%s) and parent = 'Control Panel'" % st)
-
-	if not sql("select * from `tabDefaultValue` where defkey like 'fs_%' and parent = 'Control Panel'"):
-		rs = sql("select fieldname from tabDocField where parent='Features Setup' and fieldname is not null")
-		fs = get_obj('Features Setup', 'Features Setup')
-		for d in rs:
-			fs.doc.fields[d[0]] = 1
-		fs.doc.save()
-		fs.validate()
diff --git a/patches/jan_mar_2012/pos_setting_patch.py b/patches/jan_mar_2012/pos_setting_patch.py
deleted file mode 100644
index 436f1b9..0000000
--- a/patches/jan_mar_2012/pos_setting_patch.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocField` set `default` = 1 where fieldname = 'conversion_rate' and parent = 'POS Setting'")
-
-	from webnotes.model import delete_doc
-	delete_doc('DocType', 'POS Settings')
diff --git a/patches/jan_mar_2012/print_hide_totals.py b/patches/jan_mar_2012/print_hide_totals.py
deleted file mode 100644
index 02aef92..0000000
--- a/patches/jan_mar_2012/print_hide_totals.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	"""
-		To Hide Net Total, Grand Total Export and Rounded Total Export on checking print hide
-		
-		Uncheck print_hide for fields:
-			net_total, grand_total_export and rounded_total_export
-		For DocType(s):
-			* Sales Invoice
-			* Sales Order
-			* Delivery Note
-			* Quotation
-	"""
-	webnotes.conn.sql("""\
-		UPDATE tabDocField
-		SET print_hide = 0
-		WHERE fieldname IN ('net_total', 'grand_total_export', 'rounded_total_export')
-		AND parent IN ('Sales Invoice', 'Sales Order', 'Delivery Note', 'Quotation')
-	""")
diff --git a/patches/jan_mar_2012/production_cleanup.py b/patches/jan_mar_2012/production_cleanup.py
deleted file mode 100644
index 4e5134a..0000000
--- a/patches/jan_mar_2012/production_cleanup.py
+++ /dev/null
@@ -1,86 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	from webnotes.model import delete_doc
-	sql = webnotes.conn.sql
-	
-	# Production Planning Tool
-	#---------------------------------------------------------------
-	#delete_doc('DocType', 'Production Plan Item')
-	#delete_doc('DocType', 'Production Plan Sales Order')
-	#delete_doc('DocType', 'Production Planning Tool')
-	sql("delete from `tabDocField` where parent in ('Production Planning Tool', 'Production Plan Item', 'Production Plan Sales Order')")
-	
-	reload_doc('production', 'doctype', 'production_planning_tool')
-	reload_doc('production', 'doctype', 'pp_detail')
-	reload_doc('production', 'doctype', 'pp_so_detail')
-
-	# Production Order
-	#---------------------------------------------------------------
-
-	reload_doc('production', 'doctype', 'production_order')
-
-	sql("""delete from `tabDocField` where parent = 'Production Order'
-			and (label in ('Material Transfer', 'Backflush', 'Stop Production Order', 'Unstop Production Order')
-				or fieldname = 'transaction_date')
-	""")
-
-
-	# BOM
-	#---------------------------------------------------------------
-	reload_doc('production', 'doctype', 'bill_of_materials')
-	reload_doc('production', 'doctype', 'bom_material')
-	reload_doc('production', 'doctype', 'bom_operation')
-	reload_doc('production', 'doctype', 'flat_bom_detail')
-
-	#copy values
-	sql("""update `tabBOM` set rm_cost_as_per = 'Valuation Rate', 
-		raw_material_cost = dir_mat_as_per_mar,	total_cost = cost_as_per_mar, costing_date = cost_as_on""")
-
-	sql("update `tabBOM Item` set rate = moving_avg_rate, amount = amount_as_per_mar")
-
-	sql("update `tabBOM Explosion Item` set rate = moving_avg_rate, amount = amount_as_per_mar")
-
-
-
-	# delete depricated flds from bom
-	sql("""	delete from `tabDocField` where parent = 'BOM' 
-		and (
-			label in ('TreeView1', 'Set as Default BOM', 'Activate BOM', 'Inactivate BOM') 
-			or fieldname in ('cost_as_per_mar', 'cost_as_per_lpr', 'cost_as_per_sr', 'cost_as_on',
-				'dir_mat_as_per_mar', 'dir_mat_as_per_lpr', 'dir_mat_as_per_sr')
-		)	
-	""")
-
-	# delete depricated flds from bom operation
-	sql("delete from `tabDocField` where parent = 'BOM Operation' and fieldname in ('details', 'workstation_capacity')")
-
-	# delete depricated flds from bom material
-	sql("""delete from `tabDocField` where parent = 'BOM Item' 
-		and fieldname in ('dir_mat_as_per_mar', 'dir_mat_as_per_sr', 'dir_mat_as_per_lpr', 'operating_cost', 'value_as_per_mar', 
-			'value_as_per_sr', 'value_as_per_lpr', 'moving_avg_rate', 'standard_rate', 'last_purchase_rate', 'amount_as_per_sr', 
-			'amount_as_per_lpr', 'amount_as_per_mar')	
-	""")
-
-	# delete depricated flds from flat bom
-	sql("""delete from tabDocField where parent = 'BOM Explosion Item' 
-		and fieldname in ('moving_avg_rate', 'standard_rate', 'last_purchase_rate', 'amount_as_per_mar', 
-			'amount_as_per_sr', 'amount_as_per_lpr', 'flat_bom_no', 'bom_mat_no', 'is_pro_applicable')
-	""")
diff --git a/patches/jan_mar_2012/reload_doctype.py b/patches/jan_mar_2012/reload_doctype.py
deleted file mode 100644
index f05ee76..0000000
--- a/patches/jan_mar_2012/reload_doctype.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('core', 'doctype', 'doctype')
diff --git a/patches/jan_mar_2012/reload_item.py b/patches/jan_mar_2012/reload_item.py
deleted file mode 100644
index 47800a2..0000000
--- a/patches/jan_mar_2012/reload_item.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('stock', 'doctype', 'item')
-
-	webnotes.conn.sql("update `tabItem` set re_order_qty = min_order_qty")
diff --git a/patches/jan_mar_2012/reload_mapper.py b/patches/jan_mar_2012/reload_mapper.py
deleted file mode 100644
index 146747c..0000000
--- a/patches/jan_mar_2012/reload_mapper.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-
-	reload_doc('stock', 'DocType Mapper', 'Sales Order-Delivery Note')
-	reload_doc('accounts', 'DocType Mapper', 'Sales Order-Sales Invoice')
-	reload_doc('accounts', 'DocType Mapper', 'Delivery Note-Sales Invoice')
-
-	webnotes.conn.sql("delete from `tabField Mapper Detail` where parent = 'Sales Order-Delivery Note' and from_field = 'basic_rate' and to_field = 'basic_rate'")
diff --git a/patches/jan_mar_2012/reload_po_pr_mapper.py b/patches/jan_mar_2012/reload_po_pr_mapper.py
deleted file mode 100644
index 6bed3b1..0000000
--- a/patches/jan_mar_2012/reload_po_pr_mapper.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
diff --git a/patches/jan_mar_2012/reload_quote.py b/patches/jan_mar_2012/reload_quote.py
deleted file mode 100644
index 4d23f23..0000000
--- a/patches/jan_mar_2012/reload_quote.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('selling', 'doctype', 'quotation')
diff --git a/patches/jan_mar_2012/reload_table.py b/patches/jan_mar_2012/reload_table.py
deleted file mode 100644
index 1bd4873..0000000
--- a/patches/jan_mar_2012/reload_table.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	pass
-
diff --git a/patches/jan_mar_2012/remove_archive.py b/patches/jan_mar_2012/remove_archive.py
deleted file mode 100644
index 43bb111..0000000
--- a/patches/jan_mar_2012/remove_archive.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# TODO take backup before running this patch
-from __future__ import unicode_literals
-def execute():
-	"""
-		* Restore archived data from arc tables
-		* Drop arc tables
-	"""
-	import webnotes
-	from webnotes.utils import archive
-	arc_tables = webnotes.conn.sql('show tables like "arc%"')
-	try:
-		webnotes.conn.auto_commit_on_many_writes = 1
-		for tab in arc_tables:
-			tab = tab[0]
-			dt = tab[3:]
-			res = webnotes.conn.sql("SELECT name FROM `%s`" % tab)
-			for dn in res:
-				archive.archive_doc(dt, dn[0], restore=1)
-	except Exception, e:
-		raise e
-	else:
-		webnotes.conn.commit()
-		for tab in arc_tables:
-			webnotes.conn.sql("DROP TABLE `%s`" % tab[0])
-		webnotes.conn.begin()
diff --git a/patches/jan_mar_2012/remove_get_tds_button.py b/patches/jan_mar_2012/remove_get_tds_button.py
deleted file mode 100644
index 9d254c3..0000000
--- a/patches/jan_mar_2012/remove_get_tds_button.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		Remove One Get TDS button, which is appearing twice in JV
-	"""
-	import webnotes
-	webnotes.conn.sql("""
-		DELETE from `tabDocField`
-		WHERE parent='Journal Voucher'
-		AND label='Get TDS'
-		AND fieldtype='Button'
-	""")
-
-	from webnotes.modules import reload_doc
-	reload_doc('accounts', 'doctype', 'journal_voucher')
diff --git a/patches/jan_mar_2012/remove_series_defval.py b/patches/jan_mar_2012/remove_series_defval.py
deleted file mode 100644
index 84117cf..0000000
--- a/patches/jan_mar_2012/remove_series_defval.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocField` set `default`='' where parent = 'Sales Invoice' and fieldname = 'naming_series' and `default` = 'INV'")
diff --git a/patches/jan_mar_2012/rename_dt.py b/patches/jan_mar_2012/rename_dt.py
deleted file mode 100644
index c163b49..0000000
--- a/patches/jan_mar_2012/rename_dt.py
+++ /dev/null
@@ -1,436 +0,0 @@
-from __future__ import unicode_literals
-import webnotes
-import conf
-import webnotes.model
-from wnf import replace_code
-from termcolor import colored
-from webnotes.modules import reload_doc
-from webnotes.utils import make_esc
-import os
-
-def execute1():
-	#rendt = get_dt_to_be_renamed()
-	#rename_dt_files(rendt)
-	#update_local_file_system()
-	replace_labels_with_fieldnames()
-
-def execute():
-
-	#---------------------------------------------------
-	# doctype renaming
-	rendt = get_dt_to_be_renamed()
-	# Rename dt	in db
-	rename_in_db(rendt, 'DocType', 1)
-	# Upadte dt in records
-	update_dt_in_records(rendt)
-
-	#---------------------------------------------------
-	# Dt Mapper renaming
-	ren_mapper = get_mapper_to_be_renamed()
-	# Rename mapper in db
-	rename_in_db(ren_mapper, 'DocType Mapper', 0)
-
-	#---------------------------------------------------
-	# GL Mapper renaming
-	gl_mapper = {'Receivable Voucher': 'Sales Invoice', 'Payable Voucher': 'Purchase Invoice'}
-	rename_in_db(gl_mapper, 'GL Mapper', 0)
-
-
-	#---------------------------------------------------
-	# remove dt label
-	webnotes.conn.sql("""delete from `tabDocType Label` where name in ('Ticket', 'Receivable Voucher', 
-		'QA Inspection Report', 'Payable Voucher', 'Manage Account', 'Indent', 'DocLayer')""")
-
-	#---------------------------------------------------
-	# Reload mapper from file
-	for d in ren_mapper:
-		mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s", 
-			ren_mapper[d])[0][0].lower().split())
-		reload_doc(mod, 'DocType Mapper', ren_mapper[d])
-
-	delete_search_criteria()
-	change_report_module()
-
-	# reload custom search criteria
-	#for d in  webnotes.conn.sql("""select name, module from
-	#		`tabSearch Criteria` where ifnull(standard, 'No') = 'Yes' and ifnull(disabled, 0) = 0"""):
-	#
-	for path, folders, files in os.walk(conf.modules_path):
-		if not path.endswith('search_criteria'): continue
-		module = path.split(os.sep)[-2]
-		for sc in folders:
-			try:
-				reload_doc(module, 'search_criteria', sc)
-				print module, sc
-			except Exception, e:
-				print "did not reload: " + str(d)
-	
-	webnotes.conn.sql("""DELETE FROM `tabPrint Format`
-			WHERE name IN ('Delivery Note Format', 'Purchase Order Format',
-			'Quotation Format', 'Receivable Voucher Format', 'Sales Order',
-			'SalesInvoiceModern_test', 'SalesInvoiceStdNew',
-			'Service Order Format', 'Service Quotation Format')""")
-
-	# reload custom print format
-	for d in webnotes.conn.sql("""select name, module from `tabPrint Format`
-			where ifnull(standard, 'No') = 'Yes'"""):
-		try:
-			reload_doc(d[1], 'Print Format', d[0])
-		except Exception, e:
-			print "did not reload: " + str(d)
-
-	#  Reload GL Mapper
-	for d in webnotes.conn.sql("select name from `tabGL Mapper`"):
-		reload_doc('accounts', 'GL Mapper', d[0])
-	reload_doc('accounts', 'GL Mapper', 'Purchase Invoice with write off')
-
-	webnotes.conn.sql("update `tabDocType` set module = 'Utilities' where module = 'Knowledge Base'")
-	webnotes.conn.sql("update `tabPage` set module = 'Utilities' where module = 'Knowledge Base'")
-
-		
-
-def delete_search_criteria():
-	webnotes.conn.sql("""DELETE FROM `tabSearch Criteria`
-			WHERE name IN ('', 'bills-to_be_paid',
-			'bills-to_be_submitted', 'cenvat_credit_-_input_or_capital_goods',
-			'appraisal_custom', 'custom_test', 'custom_test1', 'delivery_note-to_be_billed',
-			'delivery_note-to_be_submitted', 'delivery_notes',
-			'employee_leave_balance_report', 'flat_bom_report',
-			'general_ledger1', 'lead_interested',
-			'payables_-_as_on_outstanding', 'periodical_budget_report',
-			'projectwise_delivered_qty_and_costs_as_per_purchase_cost',
-			'projectwise_pending_qty_and_costs_as_per_purchase_cost', 'sales',
-			'sales_order1', 'sales_order_pending_items',
-			'territory_wise_sales_-_target_vs_actual_', 'test_report',
-			'lease_agreement_list', 'lease_monthly_future_installment_inflows',
-			'lease_over_due_list', 'lease_overdue_age_wise',
-			'lease_receipt_summary_month_wise', 'lease_receipts_client_wise',
-			'lease_yearly_future_installment_inflows',
-			'monthly_ledger_summary_report', 'payables_-_as_on_outstanding',
-			'payment_report', 'progressive_total_excise_duty',
-			'service_tax_credit_account_-_inputs',
-			'total_amout_collection_for_a_period_-_customerwise',
-			'invoices-to_be_submitted', 'invoices-to_receive_payment',
-			'opportunity-quotations_to_be_sent', 'purchase_order-to_be_billed',
-			'purchase_order-to_be_submitted',
-			'purchase_order-to_receive_items',
-			'purchase_request-purchase_order_to_be_made',
-			'purchase_request-to_be_submitted',
-			'sales-order_to_be_submitted', 'sales_order-overdue',
-			'sales_order-to_be_billed', 'sales_order-to_be_delivered',
-			'sales_order-to_be_submitted', 'task-open', 'appraisal_custom',
-			'employee_details', 'employee_in_company_experience',
-			'employee_leave_balance_report', 'employeewise_leave_transaction_details',
-			'pending_appraisals', 'pending_expense_claims', 'delivery_plan', 'flat_bom_report',
-			'dispatch_report', 'projectwise_delivered_qty_and_costs_as_per_purchase_cost', 
-			'projectwise_pending_qty_and_costs_as_per_purchase_cost', 'custom_test', 'custom_test1',
-			'delivery_notes', 'delivery_note_disabled', 'lead', 'lead_interested', 'lead_report',
-			'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order',
-			'sales_order1', 'sales_agentwise_commission', 'test_report', 
-			'territory_wise_sales_-_target_vs_actual_', 
-			'pending_po_items_to_bill1', 'pending_po_items_to_receive1', 
-			'expense_vouchers', 'pending_expense_vouchers', 'shortage_to_indent')""")
-
-	webnotes.conn.sql("""
-		DELETE FROM `tabSearch Criteria`
-		WHERE name IN ('monthly_transaction_summary', 'trend_analyzer',
-		'yearly_transaction_summary', 'invoices-overdue', 'lead-to_follow_up',
-		'opportunity-to_follow_up', 'serial_no-amc_expiring_this_month',
-		'serial_no-warranty_expiring_this_month')
-		AND IFNULL(standard, 'No') = 'Yes'
-		""")
-
-def change_report_module():
-	reports = {'itemwise_receipt_details': 'Stock'}
-	for k in reports:
-		webnotes.conn.sql("update `tabSearch Criteria` set module = %s where name = %s", (reports[k], k))
-
-def rename_in_db(ren_data, data_type, is_doctype):
-	for d in ren_data:
-		print colored('Renaming... ' + d + ' --> '+ ren_data[d], 'yellow')
-		#rename
-		try:
-			webnotes.model.rename(data_type, d, ren_data[d], is_doctype)
-		except Exception, e:
-			if e.args[0]!=1050:
-				raise e
-			else:
-				print e
-				pass
-
-
-def update_dt_in_records(rendt):
-	for d in rendt:
-		# Feed, property setter, search criteria, gl mapper, form 16A, naming series options, doclayer - dodtype is not mentioed in options
-		dt_list = webnotes.conn.sql("""select t1.parent, t1.fieldname from
-			tabDocField t1, tabDocType t2 where t1.parent = t2.name and
-			t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and
-			ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0 and
-			t1.parent in ('Custom Field', 'Custom Script', 'Property Setter')""")
-		for dt in dt_list:
-			webnotes.conn.sql("update `tab%s` set %s = replace(%s, '%s', '%s') where %s = '%s'" % (dt[0], dt[1], dt[1], d, rendt[d], dt[1], d))
-
-		# gl mapper, gl entry
-		webnotes.conn.sql("update `tabGL Mapper Detail` set against_voucher_type = replace(against_voucher_type, '%s', '%s') where against_voucher_type like '%%%s%%'" % (d, rendt[d], d))
-		webnotes.conn.sql("update `tabGL Entry` set against_voucher_type = replace(against_voucher_type, '%s', '%s') where against_voucher_type = '%s'" % (d, rendt[d], d))
-		webnotes.conn.sql("update `tabGL Entry` set voucher_type = replace(voucher_type, '%s', '%s') where voucher_type = '%s'" % (d, rendt[d], d))
-
-		# Stock ledger entry
-		webnotes.conn.sql("update `tabStock Ledger Entry` set voucher_type = replace(voucher_type, '%s', '%s') where voucher_type = '%s'" % (d, rendt[d], d))
-
-		# Custom fld: options
-		webnotes.conn.sql("update `tabCustom Field` set options = replace(options, %s, %s) where fieldtype in ('Link', 'Select', 'Table')", (d, rendt[d]))
-		
-		#Property Setter: value (if property=options)
-		webnotes.conn.sql("update `tabProperty Setter` set value = replace(value, %s, %s) where property = 'Options'", (d, rendt[d]))
-
-		# custom script: script
-		webnotes.conn.sql("update `tabCustom Script` set script = replace(script, %s, %s)", (d, rendt[d]))
-
-		# print format: html
-		webnotes.conn.sql("update `tabPrint Format` set html = replace(html, %s, %s) where ifnull(standard, 'Yes') = 'No'", (d, rendt[d]))
-
-		# custom report: doc_type, filters, columns, parent_doc_type, add_cond, add_col, add_tab,
-		#					dis_filters, group_by, sort_by, report_script, server_script, custom_query
-		webnotes.conn.sql("""
-			update
-				`tabSearch Criteria` 
-			set 
-				doc_type		= replace(doc_type, %s, %s), 
-				filters			= replace(filters, %s, %s), 
-				columns			= replace(columns, %s, %s), 
-				parent_doc_type = replace(parent_doc_type, %s, %s), 
-				add_cond		= replace(add_cond, %s, %s), 
-				add_col			= replace(add_col, %s, %s), 
-				add_tab			= replace(add_tab, %s, %s), 
-				dis_filters		= replace(dis_filters, %s, %s), 
-				group_by		= replace(group_by, %s, %s), 
-				sort_by			= replace(sort_by, %s, %s), 
-				report_script	= replace(report_script, %s, %s), 
-				server_script	= replace(server_script, %s, %s), 
-				custom_query	= replace(custom_query, %s, %s)
-			where 
-				ifnull(standard, 'Yes') = 'No'
-		""", (d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], 
-				d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], d, rendt[d], ))
-
-
-
-
-def get_dt_to_be_renamed():
-	rendt = {
-		'Receivable Voucher'		:	'Sales Invoice',
-		'RV Detail'					:	'Sales Invoice Item',
-		'RV Tax Detail'				:	'Sales Taxes and Charges',
-		'Payable Voucher'			:	'Purchase Invoice',
-		'PV Detail'					:	'Purchase Invoice Item',
-		'Purchase Tax Detail'		:	'Purchase Taxes and Charges',
-		'Indent'					:	'Purchase Request',
-		'Indent Detail'				:	'Purchase Request Item',
-		'QA Inspection Report'		:	'Quality Inspection',
-		'Ticket'					:	'Task',
-		'Manage Account'			:	'Global Defaults',
-		'ToDo Item'					:	'ToDo',
-		'Term'						:	'Terms and Conditions',
-		'Static Parameter Detail'	:	'SMS Parameter',
-		'SS Earning Detail'			:	'Salary Slip Earning',
-		'SS Deduction Detail'		:	'Salary Slip Deduction',
-		'Sales Order Detail'		:	'Sales Order Item',
-		'Sales BOM Detail'			:	'Sales BOM Item',
-		'Return Detail'				:	'Sales and Purchase Return Item',
-		'Ref Rate Detail'			:	'Item Price',
-		'Receiver Detail'			:	'SMS Receiver',
-		'Quotation Detail'			:	'Quotation Item',
-		'QA Specification Detail'	:	'Quality Inspection Reading',
-		'Purchase Receipt Detail'	:	'Purchase Receipt Item',
-		'Purchase Other Charges'	:	'Purchase Taxes and Charges Master',
-		'PR Raw Material Detail'	:	'Purchase Receipt Item Supplied',
-		'PP SO Detail'				:	'Production Plan Sales Order',
-		'PP Detail'					:	'Production Plan Item',
-		'PO Raw Material Detail'	:	'Purchase Order Item Supplied',
-		'PO Detail'					:	'Purchase Order Item', 
-		'Packing Slip Detail'		:	'Packing Slip Item',
-		'Other Charges'				:	'Sales Taxes and Charges Master',
-		'Order Lost Reason'			:	'Quotation Lost Reason',
-		'Manage Account'			:	'Global Defaults',
-		'Maintenance Visit Detail'	:	'Maintenance Visit Purpose',
-		'Ledger Balance Export'		:	'Multi Ledger Report',
-		'LC PR Detail'				:	'Landed Cost Purchase Receipt',
-		'Landed Cost Detail'		:	'Landed Cost Item',
-		'KRA Template'				:	'Appraisal Template',
-		'KRA Sheet'					:	'Appraisal Template Goal',
-		'Item Specification Detail' :	'Item Quality Inspection Parameter',
-		'Item Maintenance Detail'	:	'Maintenance Schedule Item',
-		'IR Payment Detail'			:	'Payment to Invoice Matching Tool Detail',
-		'Internal Reconciliation'	:	'Payment to Invoice Matching Tool',
-		'Installed Item Details'	:	'Installation Note Item',
-		'Holiday List Detail'		:	'Holiday',
-		'Follow up'					:	'Communication Log',
-		'Flat BOM Detail'			:	'BOM Explosion Item',
-		'Expense Voucher Detail'	:	'Expense Claim Detail',
-		'Expense Voucher'			:	'Expense Claim',
-		'Expense Type'				:	'Expense Claim Type',
-		'Enquiry Detail'			:	'Opportunity Item',
-		'Enquiry'					:	'Opportunity',
-		'Earning Detail'			:	'Salary Structure Earning',
-		'DocLayerField'				:	'Customize Form Field',
-		'DocLayer'					:	'Customize Form',
-		'Delivery Note Detail'		:	'Delivery Note Item',
-		'Deduction Detail'			:	'Salary Structure Deduction',
-		'Comment Widget Record'		:	'Comment',
-		'BOM Material'				:	'BOM Item',
-		'Bill Of Materials'			:	'BOM',
-		'Appraisal Detail'			:	'Appraisal Goal',
-		'Advance Allocation Detail' :	'Purchase Invoice Advance',
-		'Advance Adjustment Detail' :	'Sales Invoice Advance',
-		'Ledger Detail'				:	'Multi Ledger Report Detail',
-		'TA Control'				:	'Trend Analyzer Control',
-		'Sales and Purchase Return Wizard'	: 'Sales and Purchase Return Tool',
-		'Educational Qualifications Detail' : 'Employee Education',
-		'Delivery Note Packing Detail'		: 'Delivery Note Packing Item',
-		'Experience In Company Detail'		: 'Employee Internal Work History',
-		'Professional Training Details'		: 'Employee Training',
-		'Previous Experience Detail'		: 'Employee External Work History',
-	}
-	return rendt
-
-
-def get_mapper_to_be_renamed():
-	ren_map = {
-		'Sales Order-Receivable Voucher'	:	'Sales Order-Sales Invoice',
-		'Sales Order-Indent'				: 	'Sales Order-Purchase Request',
-		'Receivable Voucher-Delivery Note' 	: 	'Sales Invoice-Delivery Note',
-		'Purchase Receipt-Payable Voucher'	: 	'Purchase Receipt-Purchase Invoice',
-		'Purchase Order-Payable Voucher'	: 	'Purchase Order-Purchase Invoice',
-		'Project-Receivable Voucher' 		: 	'Project-Sales Invoice',
-		'Lead-Enquiry'						: 	'Lead-Opportunity',
-		'KRA Template-Appraisal'			: 	'Appraisal Template-Appraisal',
-		'Indent-Purchase Order'				: 	'Purchase Request-Purchase Order',
-		'Enquiry-Quotation'					: 	'Opportunity-Quotation',
-		'Delivery Note-Receivable Voucher'	: 	'Delivery Note-Sales Invoice'
-	}
-	return ren_map
-
-
-
-
-#--------------------------------------------------------------------------------------------------------
-
-
-def update_local_file_system():
-	""" RUN ONLY IN LOCAL"""
-	
-	# doctype renaming
-	rendt = get_dt_to_be_renamed()
-
-	# replace dt in js/py file
-	update_file_content(rendt)
-	# git mv
-	rename_dt_files(rendt)
-
-
-	# Mapper renaming
-	ren_mapper = get_mapper_to_be_renamed()
-
-	rename_mapper_files(ren_mapper)
-
-	os.system('git mv erpnext/accounts/GL\ Mapper/Payable\ Voucher erpnext/accounts/GL\ Mapper/Purchase\ Invoice')
-	os.system('git mv erpnext/accounts/GL\ Mapper/Purchase\ Invoice/Payable\ Voucher.txt erpnext/accounts/GL\ Mapper/Purchase\ Invoice/Purchase\ Invoice.txt')
-	os.system('git mv erpnext/accounts/GL\ Mapper/Receivable\ Voucher erpnext/accounts/GL\ Mapper/Sales\ Invoice')
-	os.system('git mv erpnext/accounts/GL\ Mapper/Sales\ Invoice/Receivable\ Voucher.txt erpnext/accounts/GL\ Mapper/Sales\ Invoice/Sales\ Invoice.txt')
-	
-	# git rm production dt mapper
-	os.system('git rm -r erpnext/production/DocType\ Mapper/')
-
-
-
-def update_file_content(rendt):
-	for d in rendt:
-		print colored('Renaming... ' + d + ' --> '+ rendt[d], 'yellow')
-		for extn in ['js', 'py', 'txt', 'html']:
-			res = replace_code('/var/www/erpnext/', d, rendt[d], extn)
-			if res == 'skip':
-				break
-		
-		
-def rename_dt_files(rendt):
-	for d in rendt:
-		mod = webnotes.conn.sql("select module from tabDocType where name = %s", rendt[d])[0][0]
-		if mod == 'Core':
-			os.chdir('/var/www/erpnext/lib/')
-			path = 'py/core/doctype/'
-		else:
-			os.chdir('/var/www/erpnext/')
-			path = 'erpnext/' + '_'.join(mod.lower().split()) + '/doctype/'
-		old = '_'.join(d.lower().split())
-		new = '_'.join(rendt[d].lower().split())
-
-		print 'git mv ' + path + old + ' ' + path + new
-		# rename old dir
-		os.system('git mv ' + path + old + ' ' + path + new)
-
-		# rename all files in that dir
-		for extn in ['js', 'py', 'txt', 'html']:
-			if os.path.exists(path + new + '/'+ old + '.' +extn):
-				os.system('git mv ' + path + new + '/'+ old + '.' +extn + ' ' + path + new + '/' + new + '.' +extn)
-				print 'git mv ' + path + new + '/'+ old + '.' +extn + ' ' + path + new + '/' + new + '.' +extn
-
-
-def rename_mapper_files(ren_mapper):
-	for d in ren_mapper:
-		# module
-		mod = '_'.join(webnotes.conn.sql("select module from `tabDocType Mapper` where name = %s", ren_mapper[d])[0][0].lower().split())
-		path = 'erpnext/' + mod + '/DocType Mapper/'
-
-		# rename old dir
-		esc = make_esc('$ ')
-		os.system('git mv ' + esc(path + d) + ' ' + esc(path + ren_mapper[d]))
-		print 'git mv ' + esc(path + d) + ' ' + esc(path + ren_mapper[d])
-		os.system('git mv ' + esc(path + ren_mapper[d] + '/'+ d + '.txt')
-				+ ' ' + esc(path + ren_mapper[d] + '/' + ren_mapper[d] + '.txt'))
-		print 'git mv ' + esc(path + ren_mapper[d] + '/'+ d + '.txt') + ' ' + esc(path + ren_mapper[d] + '/' + ren_mapper[d] + '.txt')
-		
-
-def replace_labels_with_fieldnames():
-	"""
-		This is used for replacing instances like cur_frm.cscript['LABEL'] with
-		cur_frm.cscript.FIELDNAME in js files
-	"""
-	doctype = {}
-	doctype.update(prepare_dict_of_label_fieldname('/var/www/erpnext/erpnext/'))
-	doctype.update(prepare_dict_of_label_fieldname('/var/www/erpnext/lib/py'))
-	#print doctype
-	
-	for doc in doctype:
-		label_fieldname = doctype[doc]
-		for d in label_fieldname:
-			#label = "cur_frm.cscript['%s']" % d
-			#fieldname = "cur_frm.cscript.%s" % label_fieldname[d]
-			label = d
-			fieldname = label_fieldname[d]
-			print colored('Changing... ' + doc + ': ' + label + ' --> '+ fieldname, 'yellow')
-			#res = replace_code('/var/www/erpnext/', label, fieldname, 'js')
-			res = replace_code('/var/www/erpnext/', label, fieldname, 'js',
-					'hide_field\(.*%s' % label)
-			if res == 'skip':
-				break
-
-def prepare_dict_of_label_fieldname(module_path):
-	from webnotes.model.utils import peval_doclist
-	from webnotes.model.sync import get_file_path
-	doctype = {}
-	for path, folders, files in os.walk(module_path):
-		if path == module_path:
-			modules_list = folders
-		for f in files:
-			if f.endswith(".txt"):
-				rel_path = os.path.relpath(path, conf.modules_path)
-				path_tuple = rel_path.split(os.sep)
-				if (len(path_tuple)==3 and path_tuple[0] in modules_list and
-						path_tuple[1] == 'doctype'):
-					file_name = f[:-4]
-					with open(get_file_path(path_tuple[0], file_name), 'r') as fn:
-						doclist = peval_doclist(fn.read())
-						doctype[file_name] = dict(([d.get('label'),d.get('fieldname')] \
-								for d in doclist if d.get('doctype')=='DocField'))
-	return doctype
diff --git a/patches/jan_mar_2012/serial_no_add_opt.py b/patches/jan_mar_2012/serial_no_add_opt.py
deleted file mode 100644
index 7693fae..0000000
--- a/patches/jan_mar_2012/serial_no_add_opt.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	opts = webnotes.conn.sql("""\
-		SELECT options FROM `tabDocField`
-		WHERE parent='Serial No' AND fieldname='status' AND
-		fieldtype='Select'""")
-	if opts and opts[0][0]:
-		opt_list = opts[0][0].split("\n")
-		if not "Purchase Returned" in opt_list:
-			webnotes.conn.sql("""
-				UPDATE `tabDocField` SET options=%s
-				WHERE parent='Serial No' AND fieldname='status' AND
-				fieldtype='Select'""", "\n".join(opt_list + ["Purchase Returned"]))
-			webnotes.conn.commit()
-			webnotes.conn.begin()
-
-	from webnotes.modules import reload_doc
-	reload_doc('stock', 'doctype', 'serial_no')
diff --git a/patches/jan_mar_2012/stable_branch_shift_09_01_12.py b/patches/jan_mar_2012/stable_branch_shift_09_01_12.py
deleted file mode 100644
index 177eb81..0000000
--- a/patches/jan_mar_2012/stable_branch_shift_09_01_12.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.modules import reload_doc
-	
-def execute():
-	"""
-		* Reload Sales Taxes and Charges
-		* Reload Support Ticket
-		* Run Install Print Format Patch
-		* Reload Customize Form
-	"""
-	reload_doc('accounts', 'doctype', 'rv_tax_detail')
-	reload_doc('support', 'doctype', 'support_ticket')
-	reload_print_formats()
-	reload_doc('core', 'doctype', 'doclayer')
-
-def reload_print_formats():
-	"""
-		Reloads the following print formats:
-		* Sales Invoice Classic/Modern/Spartan
-		* Sales Order Classic/Modern/Spartan
-		* Delivery Note Classic/Modern/Spartan
-		* Quotation Classic/Modern/Spartan
-	"""
-	reload_doc('accounts', 'Print Format', 'Sales Invoice Classic')
-	reload_doc('accounts', 'Print Format', 'Sales Invoice Modern')
-	reload_doc('accounts', 'Print Format', 'Sales Invoice Spartan')
-
-	reload_doc('selling', 'Print Format', 'Sales Order Classic')
-	reload_doc('selling', 'Print Format', 'Sales Order Modern')
-	reload_doc('selling', 'Print Format', 'Sales Order Spartan')
-
-	reload_doc('selling', 'Print Format', 'Quotation Classic')
-	reload_doc('selling', 'Print Format', 'Quotation Modern')
-	reload_doc('selling', 'Print Format', 'Quotation Spartan')
-
-	reload_doc('stock', 'Print Format', 'Delivery Note Classic')
-	reload_doc('stock', 'Print Format', 'Delivery Note Modern')
-	reload_doc('stock', 'Print Format', 'Delivery Note Spartan')
diff --git a/patches/jan_mar_2012/stock_entry_others_patch.py b/patches/jan_mar_2012/stock_entry_others_patch.py
deleted file mode 100644
index 03cc105..0000000
--- a/patches/jan_mar_2012/stock_entry_others_patch.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('stock', 'doctype', 'stock_entry')
-
-	webnotes.conn.sql("update `tabDocField` set options = concat(options, '\nOthers') where fieldname = 'purpose' and parent = 'Stock Entry'")
diff --git a/patches/jan_mar_2012/subcon_default_val.py b/patches/jan_mar_2012/subcon_default_val.py
deleted file mode 100644
index 2d0891d..0000000
--- a/patches/jan_mar_2012/subcon_default_val.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("""
-		update `tabDocField` set `default` = 'No' 
-		where parent in ('Purchase Order', 'Purchase Receipt') 
-		and fieldname = 'is_subcontracted'
-	""")
diff --git a/patches/jan_mar_2012/sync_ref_db.py b/patches/jan_mar_2012/sync_ref_db.py
deleted file mode 100644
index 5af1e54..0000000
--- a/patches/jan_mar_2012/sync_ref_db.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from __future__ import unicode_literals
-import webnotes
-sql = webnotes.conn.sql
-from webnotes.model import delete_doc
-
-def execute():
-	del_rec = {
-		'DocType'	:	['Update Series', 'File', 'File Browser Control', 'File Group',
-			'Tag Detail', 'DocType Property Setter', 'Company Group', 'Widget Control', 
-			'Update Delivery Date Detail', 'Update Delivery	Date',
-			'Tag Detail', 'Supplier rating', 'Stylesheet', 'Question Tag',
-			'PRO PP Detail', 'PRO Detail', 'PPW Detail', 'PF Detail',
-			'Personalize', 'Patch Util', 'Page Template', 'Module Def Role',
-			'Module Def Item', 'File Group', 'File Browser Control', 'File',
-			'Educational Qualifications', 'Earn Deduction Detail',
-			'DocType Property Setter', 'Contact Detail', 'BOM Report Detail', 
-			'BOM Replace Utility Detail', 'BOM Replace Utility', 
-			'Absent Days Detail', 'Activity Dashboard Control', 'Raw Materials Supplied',
-			'Setup Wizard Control', 'Company Group', 'Lease Agreement', 'Lease Installment',
-			'Terms and Conditions', 'Time Sheet', 'Time Sheet Detail', 'Naming Series Options',
-			'Invest 80 Declaration Detail', 'IT Checklist', 'Chapter VI A Detail', 'Declaration Detail',
-			'Personalize', 'Salary Slip Control Panel', 'Question Control'
-			],
-		'Page'		:	['File Browser', 'Bill of Materials', 'question-view'],
-		'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan'],
-	}
-
-	for d in del_rec:
-		for r in del_rec[d]:
-			print 'Deleted', d, ' - ', r
-			if d=='DocType':
-				sql("delete from tabFeed where doc_type=%s", r)
-			delete_doc(d, r)
-
-	sql("delete from tabDocField where label='Repair Purchase Request' and parent = 'Purchase Request'")
-
-	drop_tables()
-
-
-def drop_tables():
-	webnotes.conn.commit()
-	from webnotes.model.db_schema import remove_all_foreign_keys
-	remove_all_foreign_keys()
-	count = 0
-	tab_list = sql("SHOW TABLES")
-	for tab in tab_list:
-		if tab[0].startswith('_') or tab[0] in ('tabSingles', 'tabSessions', 'tabSeries'): continue
-		res = sql("SELECT COUNT(*) FROM `tabDocType` WHERE name = %s", tab[0][3:])
-		if not res[0][0]:
-			count += 1
-			print tab[0]
-			sql("DROP TABLE `%s`" % tab[0])
-	print count
-	webnotes.conn.begin()
diff --git a/patches/jan_mar_2012/update_purpose_se.py b/patches/jan_mar_2012/update_purpose_se.py
deleted file mode 100644
index 721ec46..0000000
--- a/patches/jan_mar_2012/update_purpose_se.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocField` set options = replace(options, 'Others', 'Other') where fieldname = 'purpose' and parent = 'Stock Entry'")
diff --git a/patches/jan_mar_2012/update_se_fld_options.py b/patches/jan_mar_2012/update_se_fld_options.py
deleted file mode 100644
index 61512d3..0000000
--- a/patches/jan_mar_2012/update_se_fld_options.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocField` set options = 'BOM' where fieldname = 'bom_no' and parent = 'Stock Entry'")
-
-	from webnotes.modules import reload_doc
-	reload_doc('stock', 'doctype', 'stock_entry')
diff --git a/patches/jan_mar_2012/update_stockreco_perm.py b/patches/jan_mar_2012/update_stockreco_perm.py
deleted file mode 100644
index b5d270f..0000000
--- a/patches/jan_mar_2012/update_stockreco_perm.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	webnotes.conn.sql("update `tabDocPerm` set cancel = 1 where parent = 'Stock Reconciliation' and ifnull(submit, 0) = 1")
diff --git a/patches/jan_mar_2012/website/__init__.py b/patches/jan_mar_2012/website/__init__.py
deleted file mode 100644
index eb05a23..0000000
--- a/patches/jan_mar_2012/website/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-
-from __future__ import unicode_literals
-	
\ No newline at end of file
diff --git a/patches/jan_mar_2012/website/all.py b/patches/jan_mar_2012/website/all.py
deleted file mode 100644
index fbb2e9d..0000000
--- a/patches/jan_mar_2012/website/all.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import patches.jan_mar_2012.website.login
-import patches.jan_mar_2012.website.feed
-import patches.jan_mar_2012.website.website
-import patches.jan_mar_2012.website.cleanups
-import patches.jan_mar_2012.website.domain_list
-import patches.jan_mar_2012.website.file_data_rename
-import patches.jan_mar_2012.website.analytics
-import patches.jan_mar_2012.website.allow_product_delete
-
-
-def execute():
-	patches.jan_mar_2012.website.login.execute()
-	patches.jan_mar_2012.website.feed.execute()
-	patches.jan_mar_2012.website.website.execute()
-	patches.jan_mar_2012.website.cleanups.execute()
-	patches.jan_mar_2012.website.domain_list.execute()
-	patches.jan_mar_2012.website.file_data_rename.execute()
-	patches.jan_mar_2012.website.analytics.execute()
-	patches.jan_mar_2012.website.allow_product_delete.execute()
diff --git a/patches/jan_mar_2012/website/allow_product_delete.py b/patches/jan_mar_2012/website/allow_product_delete.py
deleted file mode 100644
index 21dd451..0000000
--- a/patches/jan_mar_2012/website/allow_product_delete.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	"""
-		Allow deletion of products
-	"""
-	import webnotes
-	webnotes.conn.sql("""UPDATE `tabDocPerm` SET cancel=1
-		WHERE parent='Product' AND role='Website Manager'
-		AND permlevel=0""")
diff --git a/patches/jan_mar_2012/website/analytics.py b/patches/jan_mar_2012/website/analytics.py
deleted file mode 100644
index b86c8ce..0000000
--- a/patches/jan_mar_2012/website/analytics.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():	
-	from webnotes.modules import reload_doc
-	reload_doc('website', 'doctype', 'website_settings')
-	reload_doc('website', 'doctype', 'product_settings')
-	
\ No newline at end of file
diff --git a/patches/jan_mar_2012/website/cleanups.py b/patches/jan_mar_2012/website/cleanups.py
deleted file mode 100644
index 25cc63a..0000000
--- a/patches/jan_mar_2012/website/cleanups.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	from webnotes.model import delete_doc
-	from webnotes.modules import reload_doc
-	delete_doc("DocType", "SSO Control")
-	delete_doc("DocType", "WN ERP Client Control")
-	delete_doc("DocType", "Production Tips Common")
-	delete_doc("DocType", "DocTrigger")
-	delete_doc("Page", "Setup Wizard")
-	
-	# cleanup control panel
-	delete_doc("DocType", "Control Panel")
-	reload_doc("core", "doctype", "control_panel")
-	
-	webnotes.conn.sql("""delete from tabSingles
-		where field like 'startup_%' and doctype='Control Panel'""")
-	webnotes.conn.sql("""delete from __SessionCache""")
-
-	webnotes.conn.commit()
-
-	# DDLs
-	# -------------------
-	
-	webnotes.conn.sql("drop table if exists tabDocTrigger")	
-
-	try: webnotes.conn.sql("""alter table `tabFile Data` drop column blob_content""")
-	except: pass
-		
-	webnotes.conn.sql("""alter table __PatchLog engine=InnoDB""")
-	
diff --git a/patches/jan_mar_2012/website/domain_list.py b/patches/jan_mar_2012/website/domain_list.py
deleted file mode 100644
index bbac836..0000000
--- a/patches/jan_mar_2012/website/domain_list.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-def execute():
-	import webnotes
-	from webnotes.modules import reload_doc
-	reload_doc('website', 'doctype', 'website_settings')
-
-	res = webnotes.conn.sql("""\
-		SELECT name FROM `tabDocPerm`
-		WHERE parent='Website Settings' AND role='All' AND permlevel=1""")
-	if not res:
-		idx = webnotes.conn.sql("""\
-			SELECT MAX(idx) FROM `tabDocPerm`
-			WHERE parent='Website Settings'
-			""")[0][0]
-		from webnotes.model.doc import Document
-		d = Document('DocType', 'Website Settings')
-		perm = d.addchild('permissions', 'DocPerm')
-		perm.read = 1
-		perm.role = 'All'
-		perm.permlevel = 1
-		perm.idx = idx + 1
-		perm.save()
-
diff --git a/patches/jan_mar_2012/website/feed.py b/patches/jan_mar_2012/website/feed.py
deleted file mode 100644
index eae8871..0000000
--- a/patches/jan_mar_2012/website/feed.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.modules import reload_doc
-
-def execute():
-	reload_doc('home', 'doctype', 'feed')
\ No newline at end of file
diff --git a/patches/jan_mar_2012/website/file_data_rename.py b/patches/jan_mar_2012/website/file_data_rename.py
deleted file mode 100644
index 1871a78..0000000
--- a/patches/jan_mar_2012/website/file_data_rename.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	"""
-		* Replace / in names with - in tabFile Data
-		* Change autoname in DocType File Data to FileData-.#####
-		* Change FileData/ to FileData- in tabSeries
-		* In each table containing file_list column, replace / with - in the data of that column
-	"""
-	replace_name_in_file_data()
-	change_autoname_in_tabfile_data()
-	change_file_data_in_tabseries()
-	replace_file_list_column_entries()
-
-def replace_name_in_file_data():
-	"""
-		Change / to - in tabFile Data name column entries
-	"""
-	files = webnotes.conn.sql("SELECT name FROM `tabFile Data`")
-	for f in files:
-		if "/" in f[0]:
-			webnotes.conn.sql("UPDATE `tabFile Data` SET name=%s WHERE name=%s", (f[0].replace('/', '-'), f[0]))
-
-
-def change_autoname_in_tabfile_data():
-	"""
-		Change autoname in DocType File Data to FileData-.#####
-	"""
-	webnotes.conn.sql("UPDATE `tabDocType` SET autoname='FileData-.#####' WHERE name='File Data'")
-
-
-def change_file_data_in_tabseries():
-	"""
-		Change FileData/ to FileData- in tabSeries
-	"""
-	webnotes.conn.sql("UPDATE `tabSeries` SET name='FileData-' WHERE name='FileData/'")
-
-
-def replace_file_list_column_entries():
-	"""
-		In each table containing file_list column, replace / with - in the data of that column
-	"""
-	tables = webnotes.conn.sql("SHOW TABLES")
-	tab_list = []
-	for tab in tables:
-		columns = webnotes.conn.sql("DESC `%s`" % tab[0])
-		if 'file_list' in [c[0] for c in columns]:
-			tab_list.append(tab[0])
-
-	for tab in tab_list:
-		data = webnotes.conn.sql("SELECT name, file_list FROM `%s`" % tab)
-		for name, file_list in data:
-			if file_list and "/" in file_list:
-				webnotes.conn.sql("UPDATE `%s` SET file_list='%s' WHERE name='%s'" \
-					% (tab, file_list.replace('/', '-'), name))
-
-	singles = webnotes.conn.sql("""SELECT doctype, value FROM `tabSingles`
-		WHERE field='file_list'""")
-	for doctype, file_list in singles:
-		if file_list and "/" in file_list:
-			webnotes.conn.sql("""UPDATE `tabSingles` SET value='%s'
-				WHERE doctype='%s' AND field='file_list'"""
-				% (file_list.replace('/', '-'), doctype))
-
diff --git a/patches/jan_mar_2012/website/getfile_rename.py b/patches/jan_mar_2012/website/getfile_rename.py
deleted file mode 100644
index 58f70c5..0000000
--- a/patches/jan_mar_2012/website/getfile_rename.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-def execute():
-	"""rename from getfle"""
-	l = [
-		('Quotation Item', 'description'),
-		('Sales Order Item', 'description'),
-		('Delivery Note Item', 'description'),
-		('Sales Invoice Item', 'description'),
-		('Item', 'description_html'),
-		('Letter Head', 'content')
-	]
-	
-	import re
-	
-	for table in l:
-		for item in webnotes.conn.sql("""select name, %s from `tab%s` 
-			where %s like '%s'""" % (table[1], table[0], table[1], '%cgi-bin/getfile.cgi%')):
-			txt = re.sub('\&acx=[^"\']*', '', item[1])\
-				.replace('cgi-bin/getfile.cgi?name=', 'files/')\
-				.replace('FileData/', 'FileData-')
-			
-			txt = get_file_id(txt)
-			
-			webnotes.conn.sql("""update `tab%s` set %s=%s where name=%s""" % \
-				(table[0], table[1], '%s', '%s'), (txt, item[0]))
-	
-	# control panel, client name
-	txt = webnotes.conn.get_value('Control Panel',None,'client_name')
-	if txt:
-		txt = get_file_id(txt)
-		webnotes.conn.set_value('Control Panel', None, 'client_name', txt.replace('index.cgi?cmd=get_file&fname=', 'files/'))
-	
-def get_file_id(txt):
-	"""old file links may be from fileid or filename"""
-	import re
-	match = re.search('files/([^"\']*)', txt)
-
-	if not match:
-		print txt
-		return txt
-
-	fname = match.groups()[0]
-	if not fname.startswith('FileData'):
-		fid = webnotes.conn.sql("""select name from `tabFile Data` 
-			where file_name=%s""", fname)
-		if fid:
-			fid = fid[0][0].replace('/', '-')	
-			txt = txt.replace(fname, fid)
-	return txt
diff --git a/patches/jan_mar_2012/website/login.py b/patches/jan_mar_2012/website/login.py
deleted file mode 100644
index dfd8517..0000000
--- a/patches/jan_mar_2012/website/login.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.model.doc import Document
-from webnotes.modules import reload_doc
-
-def execute():
-	add_default_home_page()
-	reload_doc('setup','doctype','manage_account')
-
-	
-def add_default_home_page():
-	if not webnotes.conn.sql("""select name from `tabDefault Home Page`
-		where role='Guest' and home_page='Login Page'"""):
-		d = Document('Default Home Page')
-		d.parent = 'Control Panel'
-		d.parenttype = 'Control Panel'
-		d.parentfield = 'default_home_pages'
-		d.role = 'Guest'
-		d.home_page = 'Login Page'
-		d.save(1)
diff --git a/patches/jan_mar_2012/website/website.py b/patches/jan_mar_2012/website/website.py
deleted file mode 100644
index 8c154ca..0000000
--- a/patches/jan_mar_2012/website/website.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# website patch
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.model.doc import Document
-
-def execute():	
-	add_website_manager()
-	from webnotes.modules import reload_doc
-	from webnotes.model import delete_doc
-
-	# cleanup page
-	delete_doc("DocType", "Page")
-	reload_doc("core", "doctype", "page")
-
-	reload_doc('setup', 'doctype', 'item_group')
-	delete_doc('Website', 'Module Def', 'Website')
-	reload_doc('website', 'Module Def', 'Website')
-	reload_doc('website', 'Role', 'Website Manager')
-	reload_doc('website', 'Role', 'Blogger')
-
-	webnotes.conn.sql("""delete from `tabModule Def Role` where parent='Website'""")
-	d = Document('Module Def Role')
-	d.parent = 'Website'
-	d.role = 'Website Manager'
-	d.save()
-	
-	reload_doc('website', 'doctype', 'about_us_settings')
-	reload_doc('website', 'doctype', 'about_us_team')
-	reload_doc('website', 'doctype', 'blog')
-	reload_doc('website', 'doctype', 'contact_us_settings')
-	reload_doc('website', 'doctype', 'product')
-	reload_doc('website', 'doctype', 'product_group')
-	reload_doc('website', 'doctype', 'products_settings')
-	reload_doc('website', 'doctype', 'related_page')
-	reload_doc('website', 'doctype', 'style_settings')
-	reload_doc('website', 'doctype', 'top_bar_item')
-	reload_doc('website', 'doctype', 'web_page')
-	reload_doc('website', 'doctype', 'website_settings')
-
-	reload_doc('website', 'page', 'about')
-	reload_doc('website', 'page', 'blog')
-	reload_doc('website', 'page', 'contact')
-	reload_doc('website', 'page', 'products')
-	reload_doc('website', 'page', 'unsubscribe')
-		
-	create_home_page()
-	add_website_manager()
-
-def create_home_page():
-	"""create a dummy home page"""
-	from webnotes.model.code import get_obj
-	if not webnotes.conn.sql("""select name from `tabWeb Page` where name='home'"""):
-		d = Document('Web Page')
-		d.title = 'Home'
-		d.head_section = "<h1>Your Headline</h1>"
-		d.main_section = "<p>Some introduction about your company</p>"
-		d.side_section = "<p>Links to other pages</p>"
-		d.save()
-		obj = get_obj(doc = d)
-		obj.validate()
-		obj.doc.save()
-
-def add_website_manager():
-	"""add website manager to system manager"""
-	for i in webnotes.conn.sql("""select distinct parent from tabUserRole 
-		where role='System Manager'"""):
-		if not webnotes.conn.sql("""select parent from tabUserRole 
-			where role='Website Manager' and parent=%s""", i[0]):
-			d = Document('UserRole')
-			d.parent = i[0]
-			d.role = 'Website Manager'
-			d.save(1)
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 0b079b8..e985fa7 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -17,213 +17,6 @@
 from __future__ import unicode_literals
 patch_list = [
 	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'stable_branch_shift_09_01_12',
-		'description': 'Various Reloads for shifting branch from master to stable'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'print_hide_totals',
-		'description': 'Uncheck print_hide for RV, SO, DN and Quotation'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'rename_doctype_indent',
-		'description': 'Add DocType Label: Purchase Request to Purchase Requisition'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'production_cleanup',
-		'description': 'Major changes in production module, almost rewrited the entire code'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'jan_production_patches',
-		'description': 'Fixes after Major changes in production module'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'allocated_to_profile',
-		'description': """Change Options to "Profile" for fieldname "allocated_to"
-			as this is giving improper values in Permission Engine"""
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'remove_get_tds_button',
-		'description': "Remove One Get TDS button, which is appearing twice in JV"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'customer_address_contact_patch',
-		'description': "Install Customer Address Contact report and run patches regarding primary address and contact"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'doclabel_in_doclayer',
-		'description': "Show DocType Labels instead of DocType names in Customize Form View"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'email_settings_reload',
-		'description': "Change type of mail_port field to Int and reload email_settings doctype"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'serial_no_add_opt',
-		'description': "Add option 'Purchase Returned' to Serial No status field"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'cancel_purchase_returned',
-		'description': "Set docstatus = 2 where status = 'Purchase Returned' for serial no"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'deploy_packing_slip',
-		'description': "Delete old packing slip fields & print format & deploy new doctypes related to Packing Slip"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'map_conversion_rate',
-		'description': "Maps conversion rate in doctype mappers PO-PR and PO-PV"
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'account_type_patch',
-		'description': 'mentioed account type for some tax accounts'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'subcon_default_val',
-		'description': 'Default value of is_subcontracted in PO, PR is No'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012.website',
-		'patch_file': 'all',
-		'description': 'Run all website related patches'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'remove_archive',
-		'description': 'unarchive all records and drop archive tables'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'no_copy_patch',
-		'description': 'insert after fld in custom fld should be no_copy'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'reload_item',
-		'description': 'reload item'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'fix_packing_slip',
-		'description': 'Update Mapper Delivery Note-Packing Slip'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012.apps',
-		'patch_file': 'todo_item',
-		'description': 'Reloads todo item'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'convert_tables_to_utf8',
-		'description': 'Convert tables to UTF-8'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'pending_patches',
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'pos_setting_patch',
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'reload_doctype',
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'reload_po_pr_mapper',
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'delete_pur_of_service',
-		'description': 'Deletes purpose of service'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'navupdate',
-		'description': 'New Navigation Pages'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'label_cleanup',
-		'description': 'Remove extra fields and new dynamic labels'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'add_roles_to_admin',
-		'description': 'Add Roles to Administrator'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'dt_map_fix',
-		'description': 'removed transaction date from dt_mapper'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'reload_table',
-		'description': 'Relaod all item table: fld order changes' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'remove_series_defval',
-		'description': 'Remove rv series default value' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'update_stockreco_perm',
-		'description': 'Update stock reco permission' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'stock_entry_others_patch',
-		'description': 'new purpose others in stock entry' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'reload_quote',
-		'description': 'reload quote: organization fld added' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'update_purpose_se',
-		'description': 'Purpose SE: Others to Other' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'update_se_fld_options',
-		'description': 'Purpose SE: Others to Other' 
-	},
-	{
-		'patch_module': 'patches.mar_2012',
-		'patch_file': 'pos_invoice_fix',
-		'description': 'Reload POS Invoice' 
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'reload_mapper',
-		'description': 'SO-DN, SO-Rv, DN-RV'
-	},
-	{
-		'patch_module': 'patches.jan_mar_2012',
-		'patch_file': 'mapper_fix',
-		'description': 'DN-RV duplicate table entry'
-	},
-	{
 		'patch_module': 'patches.mar_2012',
 		'patch_file': 'so_rv_mapper_fix',
 		'description': 'SO-RV duplicate mapper entry removal'
@@ -731,6 +524,9 @@
 	},
 	{
 		'patch_module': 'patches.december_2012',
+		'patch_file': 'production_cleanup',
+	{
+		'patch_module': 'patches.december_2012',
 		'patch_file': 'fix_default_print_format',
 	},
 ]
\ No newline at end of file
diff --git a/production/__init__.py b/production/__init__.py
deleted file mode 100644
index 9ca5e3b..0000000
--- a/production/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from __future__ import unicode_literals
-install_docs = [
-	{"doctype":"Role", "role_name":"Production Manager", "name":"Production Manager"},
-	{"doctype":"Role", "role_name":"Production User", "name":"Production User"},
-]
diff --git a/production/doctype/bom_control/__init__.py b/production/doctype/bom_control/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/production/doctype/bom_control/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/production/doctype/bom_control/bom_control.py b/production/doctype/bom_control/bom_control.py
deleted file mode 100644
index 27812a8..0000000
--- a/production/doctype/bom_control/bom_control.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-from webnotes.utils import cint, flt
-from webnotes.model import db_exists
-from webnotes.model.wrapper import copy_doclist
-from webnotes.model.code import get_obj
-
-sql = webnotes.conn.sql
-
-
-	
-class DocType:
-	def __init__(self, doc, doclist):
-		self.doc = doc
-		self.doclist = doclist
-
-
-
-	def get_item_group(self):
-		ret = sql("select name from `tabItem Group` ")
-		item_group = []
-		for r in ret:
-			item =sql("select t1.name from `tabItem` t1, `tabBOM` t2 where t2.item = t1.name and t1.item_group = '%s' " % (r[0]))
-			if item and item[0][0]:
-				item_group.append(r[0])
-		return '~~~'.join([r for r in item_group])
-
-
-
-	def get_item_code(self,item_group):
-		""" here BOM docstatus = 1 and is_active ='yes' condition is not given because some bom
-			is under construction that is it is still in saved mode and they want see till where they have reach.
-		"""
-		ret = sql("select distinct t1.name from `tabItem` t1, `tabBOM` t2 where t2.item = t1.name and t1.item_group = '%s' " % (item_group))
-		return '~~~'.join([r[0] for r in ret])
-
-
-
-	def get_bom_no(self,item_code):
-		ret = sql("select name from `tabBOM` where item = '%s' " % (item_code))
-		return '~~~'.join([r[0] for r in ret])
-
-
-
-	def get_operations(self,bom_no):
-		ret = sql("select operation_no,opn_description,workstation,hour_rate,time_in_mins from `tabBOM Operation` where parent = %s", bom_no, as_dict = 1)
-		cost = sql("select dir_mat_as_per_mar , operating_cost , cost_as_per_mar from `tabBOM` where name = %s", bom_no, as_dict = 1)
-
-		# Validate the BOM ENTRIES
-		reply = []
-
-		if ret:
-			for r in ret:
-				reply.append(['operation',cint(r['operation_no']), r['opn_description'] or '','%s'% bom_no,r['workstation'],flt(r['hour_rate']),flt(r['time_in_mins']),0,0,0])
-
-			reply[0][7]= flt(cost[0]['dir_mat_as_per_mar'])
-			reply[0][8]=flt(cost[0]['operating_cost'])
-			reply[0][9]=flt(cost[0]['cost_as_per_mar'])
-		return reply
-
-
-
-	def get_item_bom(self,data):
-		data = eval(data)
-		reply = []
-		ret = sql("select item_code,description,bom_no,qty,scrap,stock_uom,value_as_per_mar,moving_avg_rate from `tabBOM Item` where parent = '%s' and operation_no = '%s'" % (data['bom_no'],data['op_no']), as_dict =1 )
-
-		for r in ret:
-			item = sql("select is_manufactured_item, is_sub_contracted_item from `tabItem` where name = '%s'" % r['item_code'], as_dict=1)
-			if not item[0]['is_manufactured_item'] == 'Yes' and not item[0]['is_sub_contracted_item'] =='Yes':
-				#if item is not manufactured or it is not sub-contracted
-				reply.append([ 'item_bom', r['item_code'] or '', r['description'] or '', r['bom_no'] or '', flt(r['qty']) or 0, r['stock_uom'] or '', flt(r['scrap']) or 0, flt(r['moving_avg_rate']) or 0, 1])
-			else:
-				# if it is manufactured or sub_contracted this will be considered(here item can be purchase item)
-				reply.append([ 'item_bom', r['item_code'] or '', r['description'] or '', r['bom_no'] or '', flt(r['qty']) or 0, r['stock_uom'] or '', flt(r['scrap']) or 0, flt(r['value_as_per_mar']) or 0, 0])
-		return reply
-
-
-
-	#------------- Wrapper Code --------------
-	def calculate_cost(self, bom_no):
-		main_bom_list = get_obj('Production Control').traverse_bom_tree( bom_no = bom_no, qty = 1, calculate_cost = 1)
-		main_bom_list.reverse()
-		for bom in main_bom_list:
-			bom_obj = get_obj('BOM', bom, with_children = 1)
-			bom_obj.calculate_cost()
-		return 'calculated'
-
-
-
-	def get_bom_tree_list(self,args):
-		arg = eval(args)
-		i =[]
-		for a in sql("select t1.name from `tabBOM` t1, `tabItem` t2 where t2.item_group like '%s' and t1.item like '%s'"%(arg['item_group'] +'%',arg['item_code'] + '%')):
-			if a[0] not in i:
-				i.append(a[0])
-		return i
diff --git a/production/doctype/bom_control/bom_control.txt b/production/doctype/bom_control/bom_control.txt
deleted file mode 100644
index 3c322e1..0000000
--- a/production/doctype/bom_control/bom_control.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# DocType, BOM Control
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2012-03-27 14:36:02',
-		'docstatus': 0,
-		'modified': '2012-03-27 14:36:02',
-		'modified_by': u'Administrator',
-		'owner': u'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'colour': u'White:FFF',
-		'doctype': 'DocType',
-		'issingle': 1,
-		'module': u'Production',
-		'name': '__common__',
-		'section_style': u'Simple',
-		'server_code_error': u' ',
-		'show_in_menu': 0,
-		'version': 108
-	},
-
-	# DocType, BOM Control
-	{
-		'doctype': 'DocType',
-		'name': u'BOM Control'
-	}
-]
\ No newline at end of file
diff --git a/production/doctype/bom_explosion_item/bom_explosion_item.txt b/production/doctype/bom_explosion_item/bom_explosion_item.txt
deleted file mode 100644
index b960231..0000000
--- a/production/doctype/bom_explosion_item/bom_explosion_item.txt
+++ /dev/null
@@ -1,137 +0,0 @@
-# DocType, BOM Explosion Item
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2012-03-27 14:36:03',
-		'docstatus': 0,
-		'modified': '2012-03-27 14:36:03',
-		'modified_by': u'Administrator',
-		'owner': u'jai@webnotestech.com'
-	},
-
-	# These values are common for all DocType
-	{
-		'autoname': u'FBD/.######',
-		'colour': u'White:FFF',
-		'doctype': 'DocType',
-		'istable': 1,
-		'module': u'Production',
-		'name': '__common__',
-		'read_only': 0,
-		'section_style': u'Simple',
-		'server_code_error': u' ',
-		'show_in_menu': 0,
-		'version': 24
-	},
-
-	# These values are common for all DocField
-	{
-		'doctype': u'DocField',
-		'name': '__common__',
-		'parent': u'BOM Explosion Item',
-		'parentfield': u'fields',
-		'parenttype': u'DocType',
-		'permlevel': 0
-	},
-
-	# DocType, BOM Explosion Item
-	{
-		'doctype': 'DocType',
-		'name': u'BOM Explosion Item'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'item_code',
-		'fieldtype': u'Link',
-		'label': u'Item Code',
-		'oldfieldname': u'item_code',
-		'oldfieldtype': u'Link',
-		'options': u'Item'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'description',
-		'fieldtype': u'Text',
-		'label': u'Description',
-		'oldfieldname': u'description',
-		'oldfieldtype': u'Text',
-		'width': u'300px'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'qty',
-		'fieldtype': u'Float',
-		'label': u'Qty',
-		'oldfieldname': u'qty',
-		'oldfieldtype': u'Currency'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'rate',
-		'fieldtype': u'Float',
-		'label': u'Rate',
-		'oldfieldname': u'standard_rate',
-		'oldfieldtype': u'Currency'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'amount',
-		'fieldtype': u'Float',
-		'label': u'Amount',
-		'oldfieldname': u'amount_as_per_sr',
-		'oldfieldtype': u'Currency'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'stock_uom',
-		'fieldtype': u'Link',
-		'label': u'Stock UOM',
-		'oldfieldname': u'stock_uom',
-		'oldfieldtype': u'Link',
-		'options': u'UOM'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'parent_bom',
-		'fieldtype': u'Link',
-		'hidden': 0,
-		'label': u'Parent BOM',
-		'oldfieldname': u'parent_bom',
-		'oldfieldtype': u'Link',
-		'width': u'250px'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'mat_detail_no',
-		'fieldtype': u'Data',
-		'hidden': 1,
-		'label': u'Mat Detail No'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'qty_consumed_per_unit',
-		'fieldtype': u'Float',
-		'hidden': 0,
-		'label': u'Qty Consumed Per Unit',
-		'no_copy': 0
-	}
-]
\ No newline at end of file
diff --git a/production/doctype/production_control/__init__.py b/production/doctype/production_control/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/production/doctype/production_control/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/production/doctype/production_control/production_control.py b/production/doctype/production_control/production_control.py
deleted file mode 100644
index b389e69..0000000
--- a/production/doctype/production_control/production_control.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-# 
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import webnotes
-
-from webnotes.utils import cstr, flt, get_defaults, now, nowdate
-from webnotes.model import db_exists
-from webnotes.model.doc import Document
-from webnotes.model.wrapper import copy_doclist
-from webnotes.model.code import get_obj
-from webnotes import msgprint
-
-sql = webnotes.conn.sql
-	
-
-	
-class DocType:
-	def __init__( self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
-		self.pur_items = {}
-		self.bom_list = []
-		self.sub_assembly_items = []
-		self.item_master = {}
-
-	def traverse_bom_tree( self, bom_no, qty, ext_pur_items = 0, ext_sub_assembly_items = 0, calculate_cost = 0, maintain_item_master = 0 ):
-		count, bom_list, qty_list = 0, [bom_no], [qty]
-		while (count < len(bom_list)):
-			# get child items from BOM MAterial Table.
-			child_items = sql("select item_code, bom_no, qty, qty_consumed_per_unit from `tabBOM Item` where parent = %s", bom_list[count], as_dict = 1)
-			child_items = child_items and child_items or []
-			for item in child_items:
-				# Calculate qty required for FG's qty.
-				item['reqd_qty'] = flt(qty) * ((count == 0) and 1 or flt(qty_list[count]) )* flt(item['qty_consumed_per_unit'])
-
-				# extracting Purchase Items
-				if ext_pur_items and not item['bom_no']:
-					self.pur_items[item['item_code']] = flt(self.pur_items.get(item['item_code'], 0)) + flt(item['reqd_qty'])
-							
-				# For calculate cost extracting BOM Items check for duplicate boms, this optmizes the time complexity for while loop.
-				if calculate_cost and item['bom_no'] and (item['bom_no'] not in bom_list):
-					bom_list.append(item['bom_no'])
-					qty_list.append(item['reqd_qty'])
-
-				# Here repeated bom are considered to calculate total qty of raw material required
-				if not calculate_cost and item['bom_no']:
-					bom_list.append(item['bom_no'])
-					qty_list.append(item['reqd_qty'])
-
-			count += 1
-		return bom_list
-
-
-
-	#	Raise Production Order
-	def create_production_order(self, items):
-		"""Create production order. Called from Production Planning Tool"""
-					 
-		default_values = { 
-			'posting_date'		: nowdate(),
-			'origin'			: 'MRP',
-			'wip_warehouse'		: '',
-			'fg_warehouse'		: '',
-			'status'			: 'Draft',
-			'fiscal_year'		: get_defaults()['fiscal_year']
-		}
-		pro_list = []
-
-		for item_so in items:
-			if item_so[1]:
-				self.validate_production_order_against_so(
-					item_so[0], item_so[1], items[item_so].get("qty"))
-				
-			pro_doc = Document('Production Order')
-			pro_doc.production_item = item_so[0]
-			pro_doc.sales_order = item_so[1]
-			for key in items[item_so]:
-				pro_doc.fields[key] = items[item_so][key]
-
-			for key in default_values:
-				pro_doc.fields[key] = default_values[key]
-			
-			pro_doc.save(new = 1)
-			pro_list.append(pro_doc.name)
-			
-		return pro_list
-
-	def validate_production_order_against_so(self, item, sales_order, qty, pro_order=None):
-		# already ordered qty
-		ordered_qty_against_so = webnotes.conn.sql("""select sum(qty) from `tabProduction Order`
-			where production_item = %s and sales_order = %s and name != %s""", 
-			(item, sales_order, cstr(pro_order)))[0][0]
-		# qty including current
-		total_ordered_qty_against_so = flt(ordered_qty_against_so) + flt(qty)
-		
-		# get qty from Sales Order Item table
-		so_item_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item` 
-			where parent = %s and item_code = %s""", (sales_order, item))[0][0]
-		# get qty from Packing Item table
-		dnpi_qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Packing Item` 
-			where parent = %s and parenttype = 'Sales Order' and item_code = %s""", 
-			(sales_order, item))[0][0]
-		# total qty in SO
-		so_qty = flt(so_item_qty) + flt(dnpi_qty)
-		
-		if total_ordered_qty_against_so > so_qty:
-			msgprint("""Total production order qty for item: %s against sales order: %s \
-			 	will be %s, which is greater than sales order qty (%s). 
-				Please reduce qty or remove the item.""" %
-				(item, sales_order, total_ordered_qty_against_so, so_qty), raise_exception=1)
-		
-	def update_bom(self, bom_no):
-		main_bom_list = self.traverse_bom_tree(bom_no, 1)
-		main_bom_list.reverse()
-		# run calculate cost and get
-		for bom in main_bom_list:
-			if bom and bom not in self.check_bom_list:
-				bom_obj = get_obj('BOM', bom, with_children = 1)
-				bom_obj.doc.save()
-				bom_obj.check_recursion()
-				bom_obj.update_flat_bom_engine()
-				bom_obj.doc.docstatus = 1
-				bom_obj.doc.save()
-				self.check_bom_list.append(bom)
\ No newline at end of file
diff --git a/production/doctype/production_control/production_control.txt b/production/doctype/production_control/production_control.txt
deleted file mode 100644
index 4f8564c..0000000
--- a/production/doctype/production_control/production_control.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# DocType, Production Control
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2012-03-27 14:36:05',
-		'docstatus': 0,
-		'modified': '2012-03-27 14:36:05',
-		'modified_by': u'Administrator',
-		'owner': u'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'colour': u'White:FFF',
-		'doctype': 'DocType',
-		'issingle': 1,
-		'module': u'Production',
-		'name': '__common__',
-		'section_style': u'Simple',
-		'server_code_error': u' ',
-		'show_in_menu': 0,
-		'version': 19
-	},
-
-	# DocType, Production Control
-	{
-		'doctype': 'DocType',
-		'name': u'Production Control'
-	}
-]
\ No newline at end of file
diff --git a/public/js/modules.js b/public/js/modules.js
index 9fa7f30..bb74884 100644
--- a/public/js/modules.js
+++ b/public/js/modules.js
@@ -21,7 +21,7 @@
 	'Buying': 'buying-home',
 	'Support': 'support-home',
 	'Projects': 'projects-home',
-	'Production': 'production-home',
+	'Manufacturing': 'manufacturing-home',
 	'Website': 'website-home',
 	'HR': 'hr-home',
 	'Setup': 'Setup',
@@ -65,7 +65,7 @@
 	'Support': 'purple',
 	'HR': 'ocean',
 	'Projects':	'violet',
-	'Production': 'dark-red',
+	'Manufacturing': 'dark-red',
 	'Website': 'leaf-green',
 	'Activity': 'brown',
 	'Setup': 'grey',
diff --git a/public/js/utils.js b/public/js/utils.js
index d02fdb3..599232d 100644
--- a/public/js/utils.js
+++ b/public/js/utils.js
@@ -103,4 +103,24 @@
 		AND tabAccount.%(key)s LIKE "%s" ' + (conditions 
 			? (" AND " + conditions.join(" AND "))
 			: "")
+}
+
+erpnext.queries.bom = function(opts) {
+	conditions = [];
+	if (opts) {
+		$.each(opts, function(key, val) {
+			if (esc_quotes(val).charAt(0) != "!")
+				conditions.push("tabBOM.`" + key + "`='"+esc_quotes(val)+"'");
+			else
+				conditions.push("tabBOM.`" + key + "`!='"+esc_quotes(val).substr(1)+"'");
+		});
+	}
+	
+	return 'SELECT tabBOM.name, tabBOM.item \
+		FROM tabBOM \
+		WHERE tabBOM.docstatus=1 \
+		AND tabBOM.is_active="Yes" \
+		AND tabBOM.%(key)s LIKE "%s" ' + (conditions.length 
+			? (" AND " + conditions.join(" AND "))
+			: "")
 }
\ No newline at end of file
diff --git a/setup/doctype/features_setup/features_setup.txt b/setup/doctype/features_setup/features_setup.txt
index cd47ce5..3045178 100644
--- a/setup/doctype/features_setup/features_setup.txt
+++ b/setup/doctype/features_setup/features_setup.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-04-13 11:56:31',
 		'docstatus': 0,
-		'modified': '2012-06-07 18:41:50',
+		'modified': '2012-12-10 18:30:00',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -273,7 +273,7 @@
 		'doctype': u'DocField',
 		'fieldname': u'production',
 		'fieldtype': u'Section Break',
-		'label': u'Production'
+		'label': u'Manufacturing'
 	},
 
 	# DocField
diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py
index 3d7e11c..fb0b694 100644
--- a/setup/doctype/setup_control/setup_control.py
+++ b/setup/doctype/setup_control/setup_control.py
@@ -237,7 +237,7 @@
 		self.add_roles(pr)
 	
 	def add_roles(self, pr):
-		roles_list = ['Accounts Manager', 'Accounts User', 'Blogger', 'HR Manager', 'HR User', 'Maintenance User', 'Maintenance Manager', 'Material Manager', 'Material User', 'Material Master Manager', 'Production Manager', 'Production User', 'Projects User', 'Purchase Manager', 'Purchase User', 'Purchase Master Manager', 'Quality Manager', 'Sales Manager', 'Sales User', 'Sales Master Manager', 'Support Manager', 'Support Team', 'System Manager', 'Website Manager']
+		roles_list = ['Accounts Manager', 'Accounts User', 'Blogger', 'HR Manager', 'HR User', 'Maintenance User', 'Maintenance Manager', 'Material Manager', 'Material User', 'Material Master Manager', 'Manufacturing Manager', 'Manufacturing User', 'Projects User', 'Purchase Manager', 'Purchase User', 'Purchase Master Manager', 'Quality Manager', 'Sales Manager', 'Sales User', 'Sales Master Manager', 'Support Manager', 'Support Team', 'System Manager', 'Website Manager']
 		for r in roles_list:
 			d = addchild(pr, 'userroles', 'UserRole', 1)
 			d.role = r
diff --git a/setup/page/modules_setup/modules_setup.js b/setup/page/modules_setup/modules_setup.js
index 71fed93..7f5b125 100644
--- a/setup/page/modules_setup/modules_setup.js
+++ b/setup/page/modules_setup/modules_setup.js
@@ -1,7 +1,7 @@
 wn.require('lib/js/lib/jquery/jquery.ui.sortable.js');
 
 $.extend(wn.pages.modules_setup, {
-	modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects', 
+	modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Manufacturing', 'Projects', 
 		'Support', 'HR', 'Website', 'To Do', 'Messages', 'Calendar', 'Knowledge Base'],	
 	onload: function(wrapper) {
 		wn.pages.modules_setup.refresh_page(wn.boot.modules_list);
@@ -11,7 +11,6 @@
 
 		// Hide Setup and Dashboard modules
 		ml.indexOf('Setup')!=-1 && ml.splice(ml.indexOf('Setup'), 1);
-		ml.indexOf('Dashboard')!=-1 && ml.splice(ml.indexOf('Dashboard'), 1);
 
 		// checked modules
 		for(i in ml) {
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 67f1643..04d898a 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -379,7 +379,7 @@
 				d.t_warehouse = self.doc.to_warehouse
 
 			if not (d.s_warehouse or d.t_warehouse):
-				msgprint("Atleast one warehouse is mandatory for Stock Entry ")
+				msgprint("Atleast one warehouse is mandatory for Stock Entry")
 				raise Exception
 			if d.s_warehouse and not sql("select name from tabWarehouse where name = '%s'" % d.s_warehouse):
 				msgprint("Invalid Warehouse: %s" % self.doc.s_warehouse)
@@ -390,6 +390,7 @@
 			if d.s_warehouse == d.t_warehouse:
 				msgprint("Source and Target Warehouse Cannot be Same.")
 				raise Exception
+				
 			if self.doc.purpose == 'Material Issue':
 				if not cstr(d.s_warehouse):
 					msgprint("Source Warehouse is Mandatory for Purpose => 'Material Issue'")
@@ -415,6 +416,7 @@
 				if not cstr(d.s_warehouse):
 					msgprint("Please Enter Source Warehouse at Row No %s." % (cstr(d.idx)))
 					raise Exception
+			
 			if self.doc.process == 'Backflush':
 				if flt(d.fg_item):
 					if cstr(pro_obj.doc.production_item) != cstr(d.item_code):
diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt
index f528430..bcba4cd 100644
--- a/stock/doctype/stock_entry/stock_entry.txt
+++ b/stock/doctype/stock_entry/stock_entry.txt
@@ -4,7 +4,7 @@
   "docstatus": 0, 
   "creation": "2012-11-28 11:26:22", 
   "modified_by": "Administrator", 
-  "modified": "2012-12-03 12:00:59"
+  "modified": "2012-12-10 18:30:00"
  }, 
  {
   "is_submittable": 1, 
@@ -793,13 +793,13 @@
   "create": 0, 
   "doctype": "DocPerm", 
   "write": 1, 
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "permlevel": 2
  }, 
  {
   "doctype": "DocPerm", 
   "write": 1, 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "permlevel": 2
  }, 
  {
@@ -808,13 +808,13 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "cancel": 1, 
   "permlevel": 0
  }, 
  {
   "doctype": "DocPerm", 
-  "role": "Production User", 
+  "role": "Manufacturing User", 
   "permlevel": 1
  }, 
  {
@@ -823,13 +823,13 @@
   "doctype": "DocPerm", 
   "submit": 1, 
   "write": 1, 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "cancel": 1, 
   "permlevel": 0
  }, 
  {
   "doctype": "DocPerm", 
-  "role": "Production Manager", 
+  "role": "Manufacturing Manager", 
   "permlevel": 1
  }, 
  {
diff --git a/tests/data/item/android_jack_d.txt b/tests/data/item/android_jack_d.txt
index 24944e3..c7edeee 100644
--- a/tests/data/item/android_jack_d.txt
+++ b/tests/data/item/android_jack_d.txt
@@ -18,6 +18,9 @@
 		'has_serial_no': u'No',
 		'inspection_required': u'No',
 		'is_purchase_item': u'Yes',
+		'is_manufactured_item': u'Yes',
+		'is_sub_contracted_item': 'Yes',
+		'is_pro_applicable': 'Yes',
 		'is_sales_item': u'Yes',
 		'is_service_item': u'No',
 		'is_stock_item': u'Yes',
diff --git a/tests/data/item/android_jack_s.txt b/tests/data/item/android_jack_s.txt
index feaceef..d32d793 100644
--- a/tests/data/item/android_jack_s.txt
+++ b/tests/data/item/android_jack_s.txt
@@ -18,6 +18,9 @@
 		'has_serial_no': u'No',
 		'inspection_required': u'No',
 		'is_purchase_item': u'Yes',
+		'is_manufactured_item': u'Yes',
+		'is_sub_contracted_item': 'Yes',
+		'is_pro_applicable': 'Yes',
 		'is_sales_item': u'Yes',
 		'is_service_item': u'No',
 		'is_stock_item': u'Yes',
diff --git a/tests/data/item/home_desktop_100.txt b/tests/data/item/home_desktop_100.txt
index 19ef01d..6745c0d 100644
--- a/tests/data/item/home_desktop_100.txt
+++ b/tests/data/item/home_desktop_100.txt
@@ -18,6 +18,7 @@
 		'has_serial_no': u'No',
 		'inspection_required': u'No',
 		'is_purchase_item': u'Yes',
+		'is_manufactured_item': u'No',
 		'is_sales_item': u'Yes',
 		'is_service_item': u'No',
 		'is_stock_item': u'Yes',