Merge branch 'master' of git@github.com:webnotes/erpnext
diff --git a/home/__init__.py b/home/__init__.py
index 36dbacf..3d1f036 100644
--- a/home/__init__.py
+++ b/home/__init__.py
@@ -91,7 +91,7 @@
 		subject = subject % doc.fields
 		make_feed(doc, subject, color)
 		
-def update_feed(doc, method):   
+def update_feed(doc, method=None):   
 	"adds a new feed"
 	if method=='validate':
 		return
diff --git a/patches/patch.py b/patches/patch.py
index 8c839e1..3d5e308 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,7 +1,7 @@
 # REMEMBER to update this
 # ========================
 
-last_patch = 315
+last_patch = 319
 
 #-------------------------------------------
 
@@ -1271,3 +1271,12 @@
 		m.parenttype = 'Module Def'
 		m.parentfield = 'roles'
 		m.save(1)
+	elif patch_no == 316:
+		pass
+	elif patch_no == 317:
+		sql("update `tabPage` set name = 'profile-settings' where page_name = 'Profile Settings'")	
+	elif patch_no == 318:
+		reload_doc('utilities', 'doctype', 'bulk_rename_tool')
+	elif patch_no == 319:
+		sql("delete from tabFeed where doc_name like 'New %'")
+
diff --git a/utilities/doctype/bulk_rename_tool/__init__.py b/utilities/doctype/bulk_rename_tool/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/utilities/doctype/bulk_rename_tool/__init__.py
diff --git a/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py b/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py
new file mode 100644
index 0000000..62d4d83
--- /dev/null
+++ b/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py
@@ -0,0 +1,82 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+class DocType:
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+	
+	# bulk rename
+	def do_rename(self):
+		import csv 
+		data = csv.reader(self.get_csv_data().splitlines())
+		
+		updated = 0
+				
+		msgprint(self.doc.rename_doctype)
+		
+		if self.doc.rename_doctype == 'Account':
+			for line in data:
+				if len(line)==2:
+					rec = sql("select tc.abbr, ta.name from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.account_name = %s", line[0], as_dict=1)
+					if rec:										
+						new_name = line[1] + ' - ' + rec[0]['abbr']						
+						
+						webnotes.conn.begin()
+						webnotes.model.rename(self.doc.rename_doctype, rec[0]['name'], new_name)						
+						sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(line[1],new_name))						
+						webnotes.conn.commit()												
+						
+						updated += 1			
+				else:
+					msgprint("[Ignored] Incorrect format: %s" % str(line))		
+		else:		
+			for line in data:
+				if len(line)==2:
+				
+					webnotes.conn.begin()				
+
+					obj = get_obj(self.doc.rename_doctype, line[0])
+					if hasattr(obj, 'on_rename'):
+						obj.on_rename(line[1],line[0])			
+
+					webnotes.model.rename(self.doc.rename_doctype, line[0], line[1])
+					
+					webnotes.conn.commit()
+						
+					updated += 1
+				else:
+					msgprint("[Ignored] Incorrect format: %s" % str(line))
+		
+		
+		msgprint("<b>%s</b> items updated" % updated)		
+
+	# Update CSV data
+	def get_csv_data(self):
+		if not self.doc.file_list:
+		  msgprint("File not attached!")
+		  raise Exception
+
+		fid = self.doc.file_list.split(',')[1]
+		  
+		from webnotes.utils import file_manager
+		fn, content = file_manager.get_file(fid)
+		
+		if not type(content) == str:
+		  content = content.tostring()
+
+		return content
diff --git a/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt b/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt
new file mode 100644
index 0000000..0accf93
--- /dev/null
+++ b/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt
@@ -0,0 +1,99 @@
+# DocType, Bulk Rename Tool
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2011-07-07 18:05:53',
+		'docstatus': 0,
+		'modified': '2011-07-07 18:51:19',
+		'modified_by': 'Administrator',
+		'owner': 'Guest'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1310035501',
+		'allow_attach': 1,
+		'autoname': 'field:rename_doctype',
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'module': 'Utilities',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'show_in_menu': 0,
+		'version': 6
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Bulk Rename Tool',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# These values are common for all DocPerm
+	{
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Bulk Rename Tool',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'read': 1,
+		'role': 'System Manager'
+	},
+
+	# DocType, Bulk Rename Tool
+	{
+		'doctype': 'DocType',
+		'name': 'Bulk Rename Tool'
+	},
+
+	# DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'permlevel': 0,
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'rename_doctype',
+		'fieldtype': 'Data',
+		'idx': 1,
+		'label': 'Rename DocType',
+		'options': 'Suggest',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'file_list',
+		'fieldtype': 'Text',
+		'idx': 2,
+		'label': 'File List'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 3,
+		'label': 'Rename',
+		'options': 'do_rename'
+	}
+]
\ No newline at end of file