[fix] rename tool #2861
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.js b/erpnext/utilities/doctype/rename_tool/rename_tool.js
index 5a33b2b..68eb0ef 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.js
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.js
@@ -1,50 +1,30 @@
 // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-cur_frm.cscript.refresh = function(doc) {
-	return frappe.call({
-		method: "erpnext.utilities.doctype.rename_tool.rename_tool.get_doctypes",
-		callback: function(r) {
-			cur_frm.set_df_property("select_doctype", "options", r.message);
-			cur_frm.cscript.setup_upload();
-		}
-	});
-}
 
-cur_frm.cscript.select_doctype = function() {
-	cur_frm.cscript.setup_upload();
-}
-
-cur_frm.cscript.setup_upload = function() {
-	var me = this;
-	var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty()
-		.html("<hr><div class='alert alert-warning'>" +
-			__("Upload a .csv file with two columns: the old name and the new name. Max 500 rows.")
-			+ "</div>");
-	var $log = $(cur_frm.fields_dict.rename_log.wrapper).empty();
-
-	// upload
-	frappe.upload.make({
-		parent: $wrapper,
-		args: {
-			method: 'erpnext.utilities.doctype.rename_tool.rename_tool.upload',
-			select_doctype: cur_frm.doc.select_doctype
-		},
-		sample_url: "e.g. http://example.com/somefile.csv",
-		callback: function(attachment, r) {
-			$log.empty().html("<hr>");
-			$.each(r.message, function(i, v) {
-				$("<div>" + v + "</div>").appendTo($log);
+frappe.ui.form.on("Rename Tool", {
+	onload: function(frm) {
+		return frappe.call({
+			method: "erpnext.utilities.doctype.rename_tool.rename_tool.get_doctypes",
+			callback: function(r) {
+				frm.set_df_property("select_doctype", "options", r.message);
+				frm.cscript.setup_upload();
+			}
+		});
+	},
+	refresh: function(frm) {
+		frm.disable_save();
+		frm.page.set_primary_action(__("Rename"), function() {
+			frm.get_field("rename_log").$wrapper.html("<p>Renaming...</p>");
+			frappe.call({
+				method: "erpnext.utilities.doctype.rename_tool.rename_tool.upload",
+				args: {
+					select_doctype: frm.doc.select_doctype
+				},
+				callback: function(r) {
+					frm.get_field("rename_log").$wrapper.html(r.message);
+				}
 			});
-		}
-	});
-
-	// rename button
-	$wrapper.find('form input[type="submit"]')
-		.click(function() {
-			$log.html("Working...");
-		})
-		.addClass("btn-primary")
-		.attr('value', 'Upload and Rename')
-
-}
+		});
+	}
+})
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.json b/erpnext/utilities/doctype/rename_tool/rename_tool.json
index 9394214..9a77f7d 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.json
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.json
@@ -13,9 +13,10 @@
    "permlevel": 0
   }, 
   {
-   "fieldname": "upload_html", 
-   "fieldtype": "HTML", 
-   "label": "Upload HTML", 
+   "description": "Attach .csv file with two columns, one for the old name and one for the new name", 
+   "fieldname": "file_to_rename", 
+   "fieldtype": "Attach", 
+   "label": "File to Rename", 
    "permlevel": 0
   }, 
   {
@@ -31,7 +32,7 @@
  "idx": 1, 
  "issingle": 1, 
  "max_attachments": 1, 
- "modified": "2015-02-05 05:11:44.714515", 
+ "modified": "2015-03-02 02:35:34.129309", 
  "modified_by": "Administrator", 
  "module": "Utilities", 
  "name": "Rename Tool", 
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py
index bd34ae1..868eedc 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.py
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py
@@ -19,7 +19,7 @@
 
 @frappe.whitelist()
 def upload(select_doctype=None, rows=None):
-	from frappe.utils.csvutils import read_csv_content_from_uploaded_file
+	from frappe.utils.csvutils import read_csv_content_from_attached_file
 	from frappe.model.rename_doc import rename_doc
 
 	if not select_doctype:
@@ -29,7 +29,7 @@
 		raise frappe.PermissionError
 
 	if not rows:
-		rows = read_csv_content_from_uploaded_file()
+		rows = read_csv_content_from_attached_file(frappe.get_doc("Rename Tool", "Rename Tool"))
 	if not rows:
 		frappe.throw(_("Please select a valid csv file with data"))