Преглед на файлове

fixed is_single_dt issue in rename function of webnotes.model

version-14
Anand Doshi преди 13 години
родител
ревизия
1c48d18dc9
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. +3
    -3
      py/webnotes/model/__init__.py

+ 3
- 3
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))


Зареждане…
Отказ
Запис