From deb38f7a6884adb20b77398101a62e56f9eed591 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 2 Sep 2015 18:34:24 +0530 Subject: [PATCH] [enhancement] document management system --- erpnext/hr/doctype/employee/employee.py | 2 +- .../patches/v4_0/reset_permissions_for_masters.py | 2 +- erpnext/patches/v5_0/execute_on_doctype_update.py | 2 +- erpnext/patches/v5_4/fix_missing_item_images.py | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index a2bb10cc69d..0d619c296d0 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -89,7 +89,7 @@ class Employee(Document): user.user_image = self.image try: frappe.get_doc({ - "doctype": "File Data", + "doctype": "File", "file_name": self.image, "attached_to_doctype": "User", "attached_to_name": self.user_id diff --git a/erpnext/patches/v4_0/reset_permissions_for_masters.py b/erpnext/patches/v4_0/reset_permissions_for_masters.py index b1b56b38131..a718cb4deec 100644 --- a/erpnext/patches/v4_0/reset_permissions_for_masters.py +++ b/erpnext/patches/v4_0/reset_permissions_for_masters.py @@ -9,7 +9,7 @@ def execute(): "Blog Category", "Blog Settings", "Blogger", "Branch", "Brand", "Buying Settings", "Comment", "Communication", "Company", "Contact Us Settings", "Country", "Currency", "Currency Exchange", "Deduction Type", "Department", - "Designation", "Earning Type", "Event", "Feed", "File Data", "Fiscal Year", + "Designation", "Earning Type", "Event", "Feed", "File", "Fiscal Year", "HR Settings", "Industry Type", "Leave Type", "Letter Head", "Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading", "Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"): diff --git a/erpnext/patches/v5_0/execute_on_doctype_update.py b/erpnext/patches/v5_0/execute_on_doctype_update.py index 4fc640e32ab..98cbd299234 100644 --- a/erpnext/patches/v5_0/execute_on_doctype_update.py +++ b/erpnext/patches/v5_0/execute_on_doctype_update.py @@ -4,5 +4,5 @@ import frappe def execute(): - for dt in ("Stock Ledger Entry", "Communication", "Comment", "DefaultValue", "DocShare", "File Data", "ToDo", "Feed"): + for dt in ("Stock Ledger Entry", "Communication", "Comment", "DefaultValue", "DocShare", "File", "ToDo", "Feed"): frappe.get_doc("DocType", dt).run_module_method("on_doctype_update") \ No newline at end of file diff --git a/erpnext/patches/v5_4/fix_missing_item_images.py b/erpnext/patches/v5_4/fix_missing_item_images.py index d782cd179ec..1dffc216cf4 100644 --- a/erpnext/patches/v5_4/fix_missing_item_images.py +++ b/erpnext/patches/v5_4/fix_missing_item_images.py @@ -37,7 +37,7 @@ def fix_files_for_item(files_path, unlinked_files): frappe.db.set_value(row.doctype, row.name, "image", new_file_url, update_modified=False) # set it as attachment of this item code - file_data = frappe.get_doc("File Data", unlinked_files[file_url]["file"]) + file_data = frappe.get_doc("File", unlinked_files[file_url]["file"]) file_data.attached_to_doctype = "Item" file_data.attached_to_name = item_code file_data.save() @@ -65,20 +65,20 @@ def rename_and_set_content_hash(files_path, unlinked_files, file_url): # set content hash if missing file_data_name = unlinked_files[file_url]["file"] - if not frappe.db.get_value("File Data", file_data_name, "content_hash"): + if not frappe.db.get_value("File", file_data_name, "content_hash"): with open(new_filename, "r") as f: content_hash = get_content_hash(f.read()) - frappe.db.set_value("File Data", file_data_name, "content_hash", content_hash) + frappe.db.set_value("File", file_data_name, "content_hash", content_hash) def get_unlinked_files(files_path): - # find files that have the same name as a File Data doc - # and the file_name mentioned in that File Data doc doesn't exist + # find files that have the same name as a File doc + # and the file_name mentioned in that File doc doesn't exist # and it isn't already attached to a doc unlinked_files = {} files = os.listdir(files_path) for file in files: - if not frappe.db.exists("File Data", {"file_name": file}): - file_data = frappe.db.get_value("File Data", {"name": file}, + if not frappe.db.exists("File", {"file_name": file}): + file_data = frappe.db.get_value("File", {"name": file}, ["file_name", "attached_to_doctype", "attached_to_name"], as_dict=True) if (file_data