From 1c48d18dc9ab9ed7e44bd7c55ab0d867f81e1d77 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 May 2012 12:34:41 +0530 Subject: [PATCH] fixed is_single_dt issue in rename function of webnotes.model --- py/webnotes/model/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/webnotes/model/__init__.py b/py/webnotes/model/__init__.py index 24baeca144..47b4369467 100644 --- a/py/webnotes/model/__init__.py +++ b/py/webnotes/model/__init__.py @@ -146,7 +146,7 @@ def get_link_fields(dt): ((options = '%s' and fieldtype='Link') or \ (options = 'link:%s' and fieldtype='Select'))" % (dt, dt)) -def rename(dt, old, new, is_doctype = 0): +def rename(dt, old, new, is_doctype=0): """ Renames a doc(dt, old) to doc(dt, new) and updates all linked fields of type "Link" or "Select" with "link:" """ @@ -169,14 +169,14 @@ def rename(dt, old, new, is_doctype = 0): update_link_fld_values(ll, old, new) # doctype - if is_doctype: + if dt=='DocType': # update options and values where select options contains old dt select_flds = sql("select parent, fieldname from `tabDocField` where parent not like 'old%%' and (options like '%%%s%%' or options like '%%%s%%') and options not like 'link:%%' and fieldtype = 'Select' and parent != '%s'" % ('\n' + old, old + '\n', new)) update_link_fld_values(select_flds, old, new) sql("update `tabDocField` set options = replace(options, '%s', '%s') where parent not like 'old%%' and (options like '%%%s%%' or options like '%%%s%%') and options not like 'link:%%' and fieldtype = 'Select' and parent != '%s'" % (old, new, '\n' + old, old + '\n', new)) - if not is_single_dt(old): + if not is_single_dt(new): sql("RENAME TABLE `tab%s` TO `tab%s`" % (old, new)) else: sql("update tabSingles set doctype = %s where doctype = %s", (new, old))