mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
[patch] [file data] patch for custom fields with name file_list
This commit is contained in:
@@ -5,28 +5,36 @@ def execute():
|
|||||||
webnotes.reload_doc("core", "doctype", "file_data")
|
webnotes.reload_doc("core", "doctype", "file_data")
|
||||||
webnotes.reset_perms("File Data")
|
webnotes.reset_perms("File Data")
|
||||||
|
|
||||||
singles = webnotes.conn.sql_list("""select name from tabDocType
|
singles = get_single_doctypes()
|
||||||
where ifnull(issingle,0)=1""")
|
|
||||||
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
|
for doctype in webnotes.conn.sql_list("""select parent from tabDocField where
|
||||||
fieldname='file_list' and fieldtype='Text'"""):
|
fieldname='file_list' and fieldtype='Text'"""):
|
||||||
if doctype in singles:
|
update_file_list(doctype, singles)
|
||||||
doc = webnotes.doc(doctype, doctype)
|
|
||||||
if doc.file_list:
|
|
||||||
update_for_doc(doctype, doc)
|
|
||||||
webnotes.conn.set_value(doctype, None, "file_list", None)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
for doc in webnotes.conn.sql("""select name, file_list from `tab%s` where
|
|
||||||
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)
|
|
||||||
except Exception, e:
|
|
||||||
if e.args[0]!=1054: raise e
|
|
||||||
|
|
||||||
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
|
webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
|
||||||
and parent=%s""", doctype)
|
and parent=%s""", doctype)
|
||||||
|
|
||||||
# export_to_files([["DocType", 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:
|
||||||
|
update_for_doc(doctype, doc)
|
||||||
|
webnotes.conn.set_value(doctype, None, "file_list", None)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
for doc in webnotes.conn.sql("""select name, file_list from `tab%s` where
|
||||||
|
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)
|
||||||
|
except Exception, e:
|
||||||
|
if e.args[0]!=1054: raise e
|
||||||
|
|
||||||
def update_for_doc(doctype, doc):
|
def update_for_doc(doctype, doc):
|
||||||
for filedata in doc.file_list.split("\n"):
|
for filedata in doc.file_list.split("\n"):
|
||||||
|
|||||||
@@ -247,4 +247,5 @@ patch_list = [
|
|||||||
"execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
|
"execute:webnotes.reload_doc('Stock', 'DocType', 'Delivery Note Item')",
|
||||||
"patches.april_2013.p06_default_cost_center",
|
"patches.april_2013.p06_default_cost_center",
|
||||||
"execute:webnotes.reset_perms('File Data')",
|
"execute:webnotes.reset_perms('File Data')",
|
||||||
|
"patches.april_2013.p07_update_file_data_custom_field",
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user