[patch] [file data] patch for custom fields with name file_list

This commit is contained in:
Anand Doshi 2013-04-29 14:12:27 +05:30
parent 457cd7d1f4
commit e5a36a287f
2 changed files with 25 additions and 16 deletions

View File

@ -5,10 +5,22 @@ def execute():
webnotes.reload_doc("core", "doctype", "file_data")
webnotes.reset_perms("File Data")
singles = webnotes.conn.sql_list("""select name from tabDocType
where ifnull(issingle,0)=1""")
singles = get_single_doctypes()
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
fieldname='file_list' and fieldtype='Text'"""):
update_file_list(doctype, singles)
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
and parent=%s""", doctype)
# export_to_files([["DocType", doctype]])
def get_single_doctypes():
return webnotes.conn.sql_list("""select name from tabDocType
where ifnull(issingle,0)=1""")
def update_file_list(doctype, singles):
if doctype in singles:
doc = webnotes.doc(doctype, doctype)
if doc.file_list:
@ -24,10 +36,6 @@ def execute():
except Exception, e:
if e.args[0]!=1054: raise e
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
and parent=%s""", doctype)
# export_to_files([["DocType", doctype]])
def update_for_doc(doctype, doc):
for filedata in doc.file_list.split("\n"):
if not filedata:

View File

@ -247,4 +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",
]