From dbe31be55c5a3429fce43b20bdc90084ea8b856f Mon Sep 17 00:00:00 2001
From: Anand Doshi
Date: Fri, 20 Jul 2012 18:11:41 +0530
Subject: [PATCH] deprecated bulk rename tool
---
.../july_2012/deprecate_bulk_rename.py | 7 +
erpnext/patches/patch_list.py | 5 +
erpnext/setup/page/setup/setup.html | 4 -
.../doctype/bulk_rename_tool/__init__.py | 1 -
.../bulk_rename_tool/bulk_rename_tool.py | 100 --------------
.../bulk_rename_tool/bulk_rename_tool.txt | 126 ------------------
6 files changed, 12 insertions(+), 231 deletions(-)
create mode 100644 erpnext/patches/july_2012/deprecate_bulk_rename.py
delete mode 100644 erpnext/utilities/doctype/bulk_rename_tool/__init__.py
delete mode 100644 erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py
delete mode 100644 erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt
diff --git a/erpnext/patches/july_2012/deprecate_bulk_rename.py b/erpnext/patches/july_2012/deprecate_bulk_rename.py
new file mode 100644
index 0000000000..d65c8b1ac4
--- /dev/null
+++ b/erpnext/patches/july_2012/deprecate_bulk_rename.py
@@ -0,0 +1,7 @@
+def execute():
+ import webnotes
+ from webnotes.model import delete_doc
+ delete_doc('DocType', 'Bulk Rename Tool')
+ webnotes.conn.commit()
+ webnotes.conn.sql("drop table `tabBulk Rename Tool`")
+ webnotes.conn.begin()
\ No newline at end of file
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 356741722c..b8720698df 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -506,4 +506,9 @@ patch_list = [
'patch_file': 'remove_event_role_owner_match',
'description': "Remove Owner match from Event DocType's Permissions"
},
+ {
+ 'patch_module': 'patches.july_2012',
+ 'patch_file': 'deprecate_bulk_rename',
+ 'description': "Remove Bulk Rename Tool"
+ },
]
\ No newline at end of file
diff --git a/erpnext/setup/page/setup/setup.html b/erpnext/setup/page/setup/setup.html
index 68da3813b6..1eca285065 100644
--- a/erpnext/setup/page/setup/setup.html
+++ b/erpnext/setup/page/setup/setup.html
@@ -49,10 +49,6 @@
Rename Master
Rename a single master record
-
- Rename Many
- Rename by uploading a csv file
-
Email and Notifications
diff --git a/erpnext/utilities/doctype/bulk_rename_tool/__init__.py b/erpnext/utilities/doctype/bulk_rename_tool/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/utilities/doctype/bulk_rename_tool/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py b/erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py
deleted file mode 100644
index 6558bc3486..0000000000
--- a/erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py
+++ /dev/null
@@ -1,100 +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 .
-
-# Please edit this list and import only required elements
-from __future__ import unicode_literals
-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, getchildren, make_autoname
-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("%s 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)
-
- # NOTE: Don't know why this condition exists
- if not isinstance(content, basestring) and hasattr(content, 'tostring'):
- content = content.tostring()
-
- return content
diff --git a/erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt b/erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt
deleted file mode 100644
index d8f9c00fae..0000000000
--- a/erpnext/utilities/doctype/bulk_rename_tool/bulk_rename_tool.txt
+++ /dev/null
@@ -1,126 +0,0 @@
-# DocType, Bulk Rename Tool
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-03-27 14:36:46',
- 'docstatus': 0,
- 'modified': '2012-03-27 14:45:46',
- 'modified_by': u'Administrator',
- 'owner': u'Administrator'
- },
-
- # These values are common for all DocType
- {
- '_last_update': u'1322549701',
- 'allow_attach': 1,
- 'autoname': u'field:rename_doctype',
- 'colour': u'White:FFF',
- 'default_print_format': u'Standard',
- 'doctype': 'DocType',
- 'is_submittable': 1,
- 'module': u'Utilities',
- 'name': '__common__',
- 'section_style': u'Simple',
- 'show_in_menu': 0,
- 'version': 8
- },
-
- # These values are common for all DocField
- {
- 'doctype': u'DocField',
- 'name': '__common__',
- 'parent': u'Bulk Rename Tool',
- 'parentfield': u'fields',
- 'parenttype': u'DocType'
- },
-
- # These values are common for all DocPerm
- {
- 'doctype': u'DocPerm',
- 'name': '__common__',
- 'parent': u'Bulk Rename Tool',
- 'parentfield': u'permissions',
- 'parenttype': u'DocType',
- 'read': 1,
- 'role': u'System Manager'
- },
-
- # DocType, Bulk Rename Tool
- {
- 'doctype': 'DocType',
- 'name': u'Bulk Rename Tool'
- },
-
- # DocPerm
- {
- 'create': 1,
- 'doctype': u'DocPerm',
- 'permlevel': 0,
- 'submit': 1,
- 'write': 1
- },
-
- # DocPerm
- {
- 'doctype': u'DocPerm',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'rename_doctype',
- 'fieldtype': u'Data',
- 'label': u'Rename DocType',
- 'options': u'Suggest',
- 'permlevel': 0,
- 'reqd': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'file_list',
- 'fieldtype': u'Text',
- 'hidden': 1,
- 'label': u'File List',
- 'no_copy': 1,
- 'permlevel': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'rename',
- 'fieldtype': u'Button',
- 'label': u'Rename',
- 'options': u'do_rename',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'depends_on': u'eval:doc.amended_from',
- 'description': u'The date at which current entry is corrected in the system.',
- 'doctype': u'DocField',
- 'fieldname': u'amendment_date',
- 'fieldtype': u'Date',
- 'label': u'Amendment Date',
- 'no_copy': 1,
- 'permlevel': 0,
- 'print_hide': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'amended_from',
- 'fieldtype': u'Link',
- 'label': u'Amended From',
- 'no_copy': 1,
- 'options': u'Sales Invoice',
- 'permlevel': 1,
- 'print_hide': 1
- }
-]
\ No newline at end of file