diff --git a/core/doctype/file_data/file_data.py b/core/doctype/file_data/file_data.py index d1138a0b31..d459ee470b 100644 --- a/core/doctype/file_data/file_data.py +++ b/core/doctype/file_data/file_data.py @@ -45,7 +45,7 @@ class DocType(): raise webnotes.DuplicateEntryError def on_trash(self): - if webnotes.conn.sql("""select count(*) from `tabFile Data` + if self.doc.file_name and webnotes.conn.sql("""select count(*) from `tabFile Data` where file_name=%s""", self.doc.file_name)[0][0]==1: path = webnotes.utils.get_path("public", "files", self.doc.file_name) if os.path.exists(path):