From 1fbc271b5d19b8721bdbc8db5309c629afee387c Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 11 Aug 2016 18:54:11 +0530 Subject: [PATCH] [Rename Tool] Fixed reading data from wrong file issue --- frappe/utils/csvutils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/utils/csvutils.py b/frappe/utils/csvutils.py index 638a1881e7..3436ea8dab 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"))