diff --git a/core/doctype/customize_form/customize_form.js b/core/doctype/customize_form/customize_form.js index 2dca543feb..353640bc1a 100644 --- a/core/doctype/customize_form/customize_form.js +++ b/core/doctype/customize_form/customize_form.js @@ -90,7 +90,7 @@ cur_frm.cscript.hide_allow_attach = function(doc, dt, dn) { 'Project', 'Profile', 'Production Order', 'Product', 'Print Format', 'Price List', 'Purchase Invoice', 'Page', 'Module Def', 'Maintenance Visit', 'Maintenance Schedule', 'Letter Head', - 'Leave Application', 'Lead', 'Journal Voucher', 'Item', 'Purchase Request', + 'Leave Application', 'Lead', 'Journal Voucher', 'Item', 'Material Request', 'Expense Claim', 'Opportunity', 'Employee', 'Delivery Note', 'Customer Issue', 'Customer', 'Contact Us Settings', 'Company', 'Blog', 'BOM', 'About Us Settings']; diff --git a/webnotes/__init__.py b/webnotes/__init__.py index feb1692e69..f58910ef85 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -338,9 +338,9 @@ def reload_doc(module, dt=None, dn=None): import webnotes.modules return webnotes.modules.reload_doc(module, dt, dn) -def rename_doc(doctype, old, new, is_doctype=0, debug=0): +def rename_doc(doctype, old, new, debug=0, force=False): from webnotes.model.rename_doc import rename_doc - rename_doc(doctype, old, new, is_doctype, debug) + rename_doc(doctype, old, new, debug, force) def insert(doclist): import webnotes.model diff --git a/webnotes/model/__init__.py b/webnotes/model/__init__.py index 0a61b5b7b5..c6961dd2a7 100644 --- a/webnotes/model/__init__.py +++ b/webnotes/model/__init__.py @@ -59,9 +59,9 @@ def get_search_criteria(dt): pass # no search criteria return dl -def rename(doctype, old, new, is_doctype=0, debug=1): +def rename(doctype, old, new, debug=1): import webnotes.model.rename_doc - webnotes.model.rename_doc.rename_doc(doctype, old, new, is_doctype, debug) + webnotes.model.rename_doc.rename_doc(doctype, old, new, debug) def copytables(srctype, src, srcfield, tartype, tar, tarfield, srcfields, tarfields=[]): import webnotes.model.doc diff --git a/webnotes/model/rename_doc.py b/webnotes/model/rename_doc.py index 1f2ec64f9f..4432ed2af9 100644 --- a/webnotes/model/rename_doc.py +++ b/webnotes/model/rename_doc.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import webnotes @webnotes.whitelist() -def rename_doc(doctype, old, new, is_doctype=0, debug=0, force=False): +def rename_doc(doctype, old, new, debug=0, force=False): """ Renames a doc(dt, old) to doc(dt, new) and updates all linked fields of type "Link" or "Select" with "link:" @@ -57,22 +57,33 @@ def rename_doc(doctype, old, new, is_doctype=0, debug=0, force=False): if debug: webnotes.errprint("executed update_link_field_values") if doctype=='DocType': - # change options for fieldtype Table - update_parent_of_fieldtype_table(old, new, debug=debug) - if debug: webnotes.errprint("executed update_parent_of_fieldtype_table") - - # change options where select options are hardcoded i.e. listed - select_fields = get_select_fields(old, new, debug=debug) - update_link_field_values(select_fields, old, new, debug=debug) - if debug: webnotes.errprint("executed update_link_field_values") - update_select_field_values(old, new, debug=debug) - if debug: webnotes.errprint("executed update_select_field_values") - - # change parenttype for fieldtype Table - update_parenttype_values(old, new, debug=debug) - if debug: webnotes.errprint("executed update_parenttype_values") + rename_doctype(doctype, old, new, debug, force) return new + +def rename_doctype(doctype, old, new, debug=0, force=False): + # change options for fieldtype Table + update_parent_of_fieldtype_table(old, new, debug=debug) + if debug: webnotes.errprint("executed update_parent_of_fieldtype_table") + + # change options where select options are hardcoded i.e. listed + select_fields = get_select_fields(old, new, debug=debug) + update_link_field_values(select_fields, old, new, debug=debug) + if debug: webnotes.errprint("executed update_link_field_values") + update_select_field_values(old, new, debug=debug) + if debug: webnotes.errprint("executed update_select_field_values") + + # change parenttype for fieldtype Table + update_parenttype_values(old, new, debug=debug) + if debug: webnotes.errprint("executed update_parenttype_values") + + # update mapper + rename_mapper(new) + +def rename_mapper(new): + for mapper in webnotes.conn.sql("""select name, from_doctype, to_doctype + from `tabDocType Mapper` where from_doctype=%s or to_doctype=%s""", (new, new), as_dict=1): + rename_doc("DocType Mapper", mapper.name, mapper.from_doctype + "-" + mapper.to_doctype, force=True) def update_child_docs(old, new, doclist, debug=0): """