Przeglądaj źródła

fixed is_single_dt issue in rename function of webnotes.model

version-14
Anand Doshi 13 lat temu
rodzic
commit
1c48d18dc9
1 zmienionych plików z 3 dodań i 3 usunięć
  1. +3
    -3
      py/webnotes/model/__init__.py

+ 3
- 3
py/webnotes/model/__init__.py Wyświetl plik

@@ -146,7 +146,7 @@ def get_link_fields(dt):
((options = '%s' and fieldtype='Link') or \ ((options = '%s' and fieldtype='Link') or \
(options = 'link:%s' and fieldtype='Select'))" % (dt, dt)) (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:" 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) update_link_fld_values(ll, old, new)


# doctype # doctype
if is_doctype:
if dt=='DocType':
# update options and values where select options contains old dt # 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)) 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) 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)) 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)) sql("RENAME TABLE `tab%s` TO `tab%s`" % (old, new))
else: else:
sql("update tabSingles set doctype = %s where doctype = %s", (new, old)) sql("update tabSingles set doctype = %s where doctype = %s", (new, old))


Ładowanie…
Anuluj
Zapisz