diff --git a/frappe/utils/csvutils.py b/frappe/utils/csvutils.py index 18b550ead1..f128d61a1b 100644 --- a/frappe/utils/csvutils.py +++ b/frappe/utils/csvutils.py @@ -18,8 +18,10 @@ def read_csv_content_from_uploaded_file(ignore_encoding=False): return read_csv_content(fcontent, ignore_encoding) def read_csv_content_from_attached_file(doc): - fileid = frappe.db.get_value("File", {"attached_to_doctype": doc.doctype, - "attached_to_name":doc.name}, "name") + fileid = frappe.get_all("File", fields = ["name"], filters = {"attached_to_doctype": doc.doctype, + "attached_to_name":doc.name}, order_by="creation desc") + + if fileid : fileid = fileid[0].name if not fileid: msgprint(_("File not attached"))