Merge branch 'renamedt' into shf_rename
This commit is contained in:
commit
8f2acae226
3 changed files with 34 additions and 12 deletions
|
|
@ -17,7 +17,7 @@ Filters can be modified declaring the customize_filters method::
|
|||
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.filter_hide = 0;
|
||||
|
||||
// add new filters
|
||||
this.add_filter({fieldname:'aging_based_on', label:'Aging Based On', fieldtype:'Select', options:NEWLINE+'Transaction Date'+NEWLINE+'Aging Date'+NEWLINE+'Due Date',ignore : 1, parent:'Receivable Voucher', report_default:'Aging Date'});
|
||||
this.add_filter({fieldname:'aging_based_on', label:'Aging Based On', fieldtype:'Select', options:NEWLINE+'Transaction Date'+NEWLINE+'Aging Date'+NEWLINE+'Due Date',ignore : 1, parent:'Sales Invoice', report_default:'Aging Date'});
|
||||
this.add_filter({fieldname:'range_1', label:'Range 1', fieldtype:'Data', ignore : 1, parent:'GL Entry'});
|
||||
|
||||
// set default filters
|
||||
|
|
@ -83,7 +83,7 @@ Values of columns can be found by label using the dictionary col_idx::
|
|||
r.append(terr and terr[0][0] or '')
|
||||
|
||||
# get due date
|
||||
due_date = sql("""select due_date from `tabReceivable Voucher`
|
||||
due_date = sql("""select due_date from `tabSales Invoice`
|
||||
where name = '%s'""" % r[col_idx['Against Voucher']])
|
||||
r.append(due_date and cstr(due_date[0][0]) or '')
|
||||
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ class DocType:
|
|||
ft = sql("select fieldtype from tabDocField where fieldname = '%s' and parent = '%s'" % (fld,tbl))
|
||||
ft = ft and ft[0][0] or ''
|
||||
if ft == 'Currency' or ft == 'Float':
|
||||
cur_val = '%.2f' % cur_val
|
||||
cur_val = '%.2f' % flt(cur_val)
|
||||
return cur_val, ft
|
||||
|
||||
# Check consistency
|
||||
|
|
|
|||
|
|
@ -141,8 +141,9 @@ 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:"
|
||||
"""
|
||||
sql = webnotes.conn.sql
|
||||
import webnotes.utils
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
# rename doc
|
||||
sql("update `tab%s` set name='%s' where name='%s'" % (dt, new, old))
|
||||
|
||||
|
|
@ -150,26 +151,47 @@ def rename(dt, old, new, is_doctype = 0):
|
|||
ct = sql("select options from tabDocField where parent = '%s' and fieldtype='Table'" % dt)
|
||||
for c in ct:
|
||||
sql("update `tab%s` set parent='%s' where parent='%s'" % (c[0], new, old))
|
||||
|
||||
# if dt is a child table of another dt
|
||||
sql("update `tabDocField` set options = '%s' where options = '%s' and fieldtype = 'Table'" % (new, old))
|
||||
|
||||
# get links (link / select)
|
||||
ll = get_link_fields(dt)
|
||||
for l in ll:
|
||||
is_single = sql("select issingle from tabDocType where name = '%s'" % l[0])
|
||||
is_single = is_single and webnotes.utils.cint(is_single[0][0]) or 0
|
||||
if is_single:
|
||||
sql("update `tabSingles` set value='%s' where field='%s' and value = '%s' and doctype = '%s' " % (new, l[1], old, l[0]))
|
||||
else:
|
||||
sql("update `tab%s` set `%s`='%s' where `%s`='%s'" % (l[0], l[1], new, l[1], old))
|
||||
update_link_fld_values(ll, old, new)
|
||||
|
||||
# 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%%' and options not like 'link:%%' and fieldtype = 'Select' and parent != '%s'" % (old, new))
|
||||
update_link_fld_values(select_flds, old, new)
|
||||
|
||||
sql("update `tabDocField` set options = replace(options, '%s', '%s') where options like '%%%s%%'" % (old, new, old))
|
||||
|
||||
|
||||
# doctype
|
||||
if is_doctype:
|
||||
sql("RENAME TABLE `tab%s` TO `tab%s`" % (old, new))
|
||||
if not is_single_dt(old):
|
||||
sql("RENAME TABLE `tab%s` TO `tab%s`" % (old, new))
|
||||
else:
|
||||
sql("update tabSingles set doctype = %s where doctype = %s", (new, old))
|
||||
|
||||
# get child docs (update parenttype)
|
||||
ct = sql("select options from tabDocField where parent = '%s' and fieldtype='Table'" % new)
|
||||
for c in ct:
|
||||
sql("update `tab%s` set parenttype='%s' where parenttype='%s'" % (c[0], new, old))
|
||||
|
||||
|
||||
|
||||
def update_link_fld_values(flds, old, new):
|
||||
for l in flds:
|
||||
if is_single_dt(l[0]):
|
||||
webnotes.conn.sql("update `tabSingles` set value='%s' where field='%s' and value = '%s' and doctype = '%s' " % (new, l[1], old, l[0]))
|
||||
else:
|
||||
webnotes.conn.sql("update `tab%s` set `%s`='%s' where `%s`='%s'" % (l[0], l[1], new, l[1], old))
|
||||
|
||||
def is_single_dt(dt):
|
||||
is_single = webnotes.conn.sql("select issingle from tabDocType where name = '%s'" % dt)
|
||||
is_single = is_single and webnotes.utils.cint(is_single[0][0]) or 0
|
||||
return is_single
|
||||
|
||||
#=================================================================================
|
||||
|
||||
def clear_recycle_bin():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue