From c9df2e5922ae4a28e83746712a70e74f675108ee Mon Sep 17 00:00:00 2001 From: mbauskar Date: Thu, 14 Sep 2017 17:22:16 +0530 Subject: [PATCH] [minor] update the image field value if file's is_private value changed --- frappe/core/doctype/file/file.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index 4341d557aa..1976f4c862 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -76,6 +76,7 @@ class File(NestedSet): if frappe.db.exists('File', {'name': self.name, 'is_folder': 0}): if not self.is_folder and (self.is_private != self.db_get('is_private')): + old_file_url = self.file_url private_files = frappe.get_site_path('private', 'files') public_files = frappe.get_site_path('public', 'files') @@ -91,6 +92,11 @@ class File(NestedSet): self.file_url = "/private/files/{0}".format(self.file_name) + # update documents image url with new file url + if self.attached_to_doctype and self.attached_to_name and \ + frappe.db.get_value(self.attached_to_doctype, self.attached_to_name, "image") == old_file_url: + frappe.db.set_value(self.attached_to_doctype, self.attached_to_name, "image", self.file_url) + def set_folder_size(self): """Set folder size if folder""" if self.is_folder and not self.is_new():