added rename tool
diff --git a/patches/patch.py b/patches/patch.py
index 3bc3361..334b656 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,6 +1,6 @@
# REMEMBER to update this
# ========================
-last_patch = 290
+last_patch = 291
#-------------------------------------------
@@ -1159,4 +1159,7 @@
md = Document('Module Def')
md.module_name = 'Home'
md.module_label = 'Home'
- md.save(1)
\ No newline at end of file
+ md.save(1)
+ elif patch_no == 291:
+ relaod_doc('tools','doctype','rename_tool')
+
\ No newline at end of file
diff --git a/setup/page/setup/setup.js b/setup/page/setup/setup.js
index ae4a835..c0ba3d4 100644
--- a/setup/page/setup/setup.js
+++ b/setup/page/setup/setup.js
@@ -182,6 +182,7 @@
['Currency',1,'Currency','','Manage list of currencies'],
['Country',1,'Country','','Country master'],
['State',1,'State','','State master'],
+ ['Rename Tool',3,'Rename Tool','','Rename a record'],
['Activty Type',1,'Activity Type','','Types of activities that you can select in your Timesheet'],
['City',1,'City','','City master']]};
diff --git a/tools/doctype/rename_tool/__init__.py b/tools/doctype/rename_tool/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/tools/doctype/rename_tool/__init__.py
diff --git a/tools/doctype/rename_tool/__init__.pyc b/tools/doctype/rename_tool/__init__.pyc
new file mode 100755
index 0000000..11d1798
--- /dev/null
+++ b/tools/doctype/rename_tool/__init__.pyc
Binary files differ
diff --git a/tools/doctype/rename_tool/rename_tool.js b/tools/doctype/rename_tool/rename_tool.js
new file mode 100644
index 0000000..bcd156e
--- /dev/null
+++ b/tools/doctype/rename_tool/rename_tool.js
@@ -0,0 +1,5 @@
+// over-ride the link query to return relevant link names
+
+cur_frm.fields_dict.document_to_rename.get_query = function(doc, dt, dn) {
+ return "SELECT name FROM `tab"+doc.select_doctype+"` WHERE docstatus<2 AND name LIKE '%s' LIMIT 50";
+}
\ No newline at end of file
diff --git a/tools/doctype/rename_tool/rename_tool.py b/tools/doctype/rename_tool/rename_tool.py
new file mode 100644
index 0000000..9b91193
--- /dev/null
+++ b/tools/doctype/rename_tool/rename_tool.py
@@ -0,0 +1,20 @@
+class DocType:
+ def __init__(self, d, dl=[]):
+ self.doc, self.doclist = d, dl
+
+ def rename(self):
+ """
+ Generate update quereies for rename
+ """
+ import webnotes.model
+ from webnotes.model.code import get_obj
+
+ # call on_rename method if exists
+ obj = get_obj(self.doc.select_doctype, self.doc.document_to_rename)
+ if hasattr(obj, 'on_rename'):
+ obj.on_rename(self.doc.new_name)
+
+ # rename the document
+ webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)
+
+ webnotes.msgprint("Item renamed successfully")
\ No newline at end of file
diff --git a/tools/doctype/rename_tool/rename_tool.pyc b/tools/doctype/rename_tool/rename_tool.pyc
new file mode 100644
index 0000000..dc919ab
--- /dev/null
+++ b/tools/doctype/rename_tool/rename_tool.pyc
Binary files differ
diff --git a/tools/doctype/rename_tool/rename_tool.txt b/tools/doctype/rename_tool/rename_tool.txt
new file mode 100755
index 0000000..a2df8c5
--- /dev/null
+++ b/tools/doctype/rename_tool/rename_tool.txt
@@ -0,0 +1,225 @@
+[
+ {
+ '_last_update': '1308739509',
+ 'allow_attach': None,
+ 'allow_copy': None,
+ 'allow_email': 1,
+ 'allow_print': 1,
+ 'allow_rename': None,
+ 'allow_trash': None,
+ 'autoname': None,
+ 'change_log': None,
+ 'client_script': None,
+ 'client_script_core': None,
+ 'client_string': None,
+ 'colour': 'White:FFF',
+ 'creation': '2011-06-22 16:08:49',
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocType',
+ 'document_type': None,
+ 'dt_template': None,
+ 'hide_heading': 0,
+ 'hide_toolbar': 0,
+ 'idx': None,
+ 'in_create': None,
+ 'in_dialog': None,
+ 'is_transaction_doc': None,
+ 'issingle': 1,
+ 'istable': None,
+ 'max_attachments': None,
+ 'menu_index': None,
+ 'modified': '2011-06-22 16:24:18',
+ 'modified_by': 'Administrator',
+ 'module': 'Tools',
+ 'name': 'Rename Tool',
+ 'name_case': None,
+ 'owner': 'Administrator',
+ 'parent': None,
+ 'parent_node': None,
+ 'parentfield': None,
+ 'parenttype': None,
+ 'print_outline': None,
+ 'read_only': None,
+ 'read_only_onload': None,
+ 'search_fields': None,
+ 'section_style': 'Simple',
+ 'server_code': None,
+ 'server_code_compiled': None,
+ 'server_code_core': None,
+ 'server_code_error': None,
+ 'show_in_menu': 0,
+ 'smallicon': None,
+ 'subject': None,
+ 'tag_fields': None,
+ 'use_template': None,
+ 'version': 6
+ },
+ {
+ 'amend': None,
+ 'cancel': None,
+ 'create': 1,
+ 'creation': '2011-06-22 16:08:49',
+ 'docstatus': 0,
+ 'doctype': 'DocPerm',
+ 'execute': None,
+ 'idx': 1,
+ 'match': None,
+ 'modified': '2011-06-22 16:24:18',
+ 'modified_by': 'Administrator',
+ 'name': 'PERM00829',
+ 'owner': 'Administrator',
+ 'parent': 'Rename Tool',
+ 'parentfield': 'permissions',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'role': 'System Manager',
+ 'submit': None,
+ 'write': 1
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-06-22 16:08:49',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'select_doctype',
+ 'fieldtype': 'Select',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 1,
+ 'in_filter': None,
+ 'label': 'Select DocType',
+ 'modified': '2011-06-22 16:24:18',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05282',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'link:DocType',
+ 'owner': 'Administrator',
+ 'parent': 'Rename Tool',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-06-22 16:08:49',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'document_to_rename',
+ 'fieldtype': 'Link',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 2,
+ 'in_filter': None,
+ 'label': 'Document to rename',
+ 'modified': '2011-06-22 16:24:18',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05283',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Rename Tool',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-06-22 16:08:49',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': 'new_name',
+ 'fieldtype': 'Data',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 3,
+ 'in_filter': None,
+ 'label': 'New Name',
+ 'modified': '2011-06-22 16:24:18',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05284',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': None,
+ 'owner': 'Administrator',
+ 'parent': 'Rename Tool',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ },
+ {
+ 'allow_on_submit': None,
+ 'colour': None,
+ 'creation': '2011-06-22 16:08:49',
+ 'default': None,
+ 'depends_on': None,
+ 'description': None,
+ 'docstatus': 0,
+ 'doctype': 'DocField',
+ 'fieldname': None,
+ 'fieldtype': 'Button',
+ 'hidden': None,
+ 'icon': None,
+ 'idx': 4,
+ 'in_filter': None,
+ 'label': 'Rename',
+ 'modified': '2011-06-22 16:24:18',
+ 'modified_by': 'Administrator',
+ 'name': 'FL05285',
+ 'no_column': None,
+ 'no_copy': None,
+ 'oldfieldname': None,
+ 'oldfieldtype': None,
+ 'options': 'rename',
+ 'owner': 'Administrator',
+ 'parent': 'Rename Tool',
+ 'parentfield': 'fields',
+ 'parenttype': 'DocType',
+ 'permlevel': 0,
+ 'print_hide': None,
+ 'report_hide': None,
+ 'reqd': None,
+ 'search_index': None,
+ 'trigger': None,
+ 'width': None
+ }
+]
\ No newline at end of file