Browse Source

fixes in rename doc

version-14
Anand Doshi 12 years ago
parent
commit
0ec65a8e87
4 changed files with 31 additions and 20 deletions
  1. +1
    -1
      core/doctype/customize_form/customize_form.js
  2. +2
    -2
      webnotes/__init__.py
  3. +2
    -2
      webnotes/model/__init__.py
  4. +26
    -15
      webnotes/model/rename_doc.py

+ 1
- 1
core/doctype/customize_form/customize_form.js View File

@@ -90,7 +90,7 @@ cur_frm.cscript.hide_allow_attach = function(doc, dt, dn) {
'Project', 'Profile', 'Production Order', 'Product', 'Print Format', 'Project', 'Profile', 'Production Order', 'Product', 'Print Format',
'Price List', 'Purchase Invoice', 'Page', 'Module Def', 'Price List', 'Purchase Invoice', 'Page', 'Module Def',
'Maintenance Visit', 'Maintenance Schedule', 'Letter Head', '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', 'Expense Claim', 'Opportunity', 'Employee', 'Delivery Note',
'Customer Issue', 'Customer', 'Contact Us Settings', 'Company', 'Customer Issue', 'Customer', 'Contact Us Settings', 'Company',
'Blog', 'BOM', 'About Us Settings']; 'Blog', 'BOM', 'About Us Settings'];


+ 2
- 2
webnotes/__init__.py View File

@@ -338,9 +338,9 @@ def reload_doc(module, dt=None, dn=None):
import webnotes.modules import webnotes.modules
return webnotes.modules.reload_doc(module, dt, dn) 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 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): def insert(doclist):
import webnotes.model import webnotes.model


+ 2
- 2
webnotes/model/__init__.py View File

@@ -59,9 +59,9 @@ def get_search_criteria(dt):
pass # no search criteria pass # no search criteria
return dl return dl


def rename(doctype, old, new, is_doctype=0, debug=1):
def rename(doctype, old, new, debug=1):
import webnotes.model.rename_doc 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=[]): def copytables(srctype, src, srcfield, tartype, tar, tarfield, srcfields, tarfields=[]):
import webnotes.model.doc import webnotes.model.doc


+ 26
- 15
webnotes/model/rename_doc.py View File

@@ -2,7 +2,7 @@ from __future__ import unicode_literals
import webnotes import webnotes


@webnotes.whitelist() @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 Renames a doc(dt, old) to doc(dt, new) and
updates all linked fields of type "Link" or "Select" with "link:" 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 debug: webnotes.errprint("executed update_link_field_values")
if doctype=='DocType': 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 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): def update_child_docs(old, new, doclist, debug=0):
""" """


Loading…
Cancel
Save