[patches] [file data] fixes in file data patch
This commit is contained in:
parent
e5a36a287f
commit
123f59dc89
@ -53,10 +53,17 @@ def update_for_doc(doctype, doc):
|
|||||||
exists = False
|
exists = False
|
||||||
|
|
||||||
if exists:
|
if exists:
|
||||||
webnotes.conn.sql("""update `tabFile Data`
|
if webnotes.conn.exists("File Data", fileid):
|
||||||
set attached_to_doctype=%s, attached_to_name=%s
|
fd = webnotes.bean("File Data", fileid)
|
||||||
where name=%s""", (doctype, doc.name, fileid))
|
if not (fd.doc.attached_to_doctype and fd.doc.attached_to_name):
|
||||||
|
fd.doc.attached_to_doctype = doctype
|
||||||
|
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()
|
||||||
else:
|
else:
|
||||||
webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
|
webnotes.conn.sql("""delete from `tabFile Data` where name=%s""",
|
||||||
fileid)
|
fileid)
|
Loading…
x
Reference in New Issue
Block a user