fixes in rename doc
This commit is contained in:
parent
ce32bba6b8
commit
0ec65a8e87
4 changed files with 31 additions and 20 deletions
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue