[patch] [fiel data] new patch p07_update_file_data_2
This commit is contained in:
parent
7bd7c8769e
commit
eda17eb20a
@ -8,7 +8,7 @@ def execute():
|
||||
singles = get_single_doctypes()
|
||||
|
||||
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
|
||||
fieldname='file_list' and fieldtype='Text'"""):
|
||||
fieldname='file_list'"""):
|
||||
update_file_list(doctype, singles)
|
||||
|
||||
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
|
||||
@ -32,9 +32,11 @@ def update_file_list(doctype, singles):
|
||||
ifnull(file_list, '')!=''""" % doctype, as_dict=True):
|
||||
update_for_doc(doctype, doc)
|
||||
webnotes.conn.commit()
|
||||
webnotes.conn.sql("""alter table `tab%s` drop column file_list""" % doctype)
|
||||
webnotes.conn.sql("""alter table `tab%s` drop column `file_list`""" % doctype)
|
||||
except Exception, e:
|
||||
if e.args[0]!=1054: raise e
|
||||
print webnotes.getTraceback()
|
||||
if (e.args and e.args[0]!=1054) or not e.args:
|
||||
raise e
|
||||
|
||||
def update_for_doc(doctype, doc):
|
||||
for filedata in doc.file_list.split("\n"):
|
||||
@ -60,10 +62,14 @@ def update_for_doc(doctype, doc):
|
||||
fd.doc.attached_to_name = doc.name
|
||||
fd.save()
|
||||
else:
|
||||
fd = webnotes.bean("File Data", copy=fd.doclist)
|
||||
fd.doc.attached_to_doctype = doctype
|
||||
fd.doc.attached_to_name = doc.name
|
||||
fd.insert()
|
||||
try:
|
||||
fd = webnotes.bean("File Data", copy=fd.doclist)
|
||||
fd.doc.attached_to_doctype = doctype
|
||||
fd.doc.attached_to_name = doc.name
|
||||
fd.doc.name = None
|
||||
fd.insert()
|
||||
except webnotes.DuplicateEntryError:
|
||||
pass
|
||||
else:
|
||||
webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
|
||||
fileid)
|
15
patches/april_2013/p07_update_file_data_2.py
Normal file
15
patches/april_2013/p07_update_file_data_2.py
Normal file
@ -0,0 +1,15 @@
|
||||
import webnotes
|
||||
def execute():
|
||||
from patches.april_2013.p05_update_file_data import update_file_list, get_single_doctypes
|
||||
|
||||
singles = get_single_doctypes()
|
||||
for doctype in webnotes.conn.sql_list("""select table_name from `information_schema`.`columns`
|
||||
where table_schema=%s and column_name='file_list'""", webnotes.conn.cur_db_name):
|
||||
doctype = doctype[3:]
|
||||
update_file_list(doctype, singles)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list'
|
||||
and parent=%s""", doctype)
|
||||
webnotes.conn.sql("""delete from `tabDocField` where fieldname='file_list'
|
||||
and parent=%s""", doctype)
|
||||
|
@ -1,11 +0,0 @@
|
||||
import webnotes
|
||||
def execute():
|
||||
from patches.april_2013.p05_update_file_data import update_file_list, get_single_doctypes
|
||||
singles = get_single_doctypes()
|
||||
for doctype in webnotes.conn.sql("""select parent from `tabCustom Field` where
|
||||
fieldname='file_list' and fieldtype='Text'"""):
|
||||
update_file_list(doctype, singles)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabCustom Field` where fieldname='file_list'
|
||||
and parent=%s""", doctype)
|
||||
|
@ -247,5 +247,5 @@ patch_list = [
|
||||
"execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
|
||||
"patches.april_2013.p06_default_cost_center",
|
||||
"execute:webnotes.reset_perms('File Data')",
|
||||
"patches.april_2013.p07_update_file_data_custom_field",
|
||||
"patches.april_2013.p07_update_file_data_2",
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user