diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.js b/erpnext/utilities/doctype/rename_tool/rename_tool.js index 5a33b2bf5b4..68eb0ef1812 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("
Renaming...
"); + 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 93942148351..9a77f7d3b22 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 bd34ae1c9e4..868eedcc856 100644 --- a/erpnext/utilities/doctype/rename_tool/rename_tool.py +++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py @@ -19,7 +19,7 @@ def get_doctypes(): @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 @@ def upload(select_doctype=None, rows=None): 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"))