diff --git a/frappe/__init__.py b/frappe/__init__.py index e89515951f..6e397647dc 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template -__version__ = '10.0.9' +__version__ = '10.0.10' __title__ = "Frappe Framework" local = Local() diff --git a/frappe/core/doctype/file/file.json b/frappe/core/doctype/file/file.json index d3275e6968..e1be754a67 100644 --- a/frappe/core/doctype/file/file.json +++ b/frappe/core/doctype/file/file.json @@ -520,6 +520,36 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "attached_to_field", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Attached To Field", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -653,7 +683,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2017-10-27 13:27:43.882914", + "modified": "2018-01-15 03:41:23.876072", "modified_by": "Administrator", "module": "Core", "name": "File", diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index 03701e5ba0..1c6a0edceb 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -75,8 +75,8 @@ class File(NestedSet): self.set_folder_size() if frappe.db.exists('File', {'name': self.name, 'is_folder': 0}): + old_file_url = self.file_url 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') @@ -92,10 +92,20 @@ 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) + if self.attached_to_doctype and self.attached_to_name: + if not self.attached_to_field: + field_name = None + reference_dict = frappe.get_doc(self.attached_to_doctype, self.attached_to_name).as_dict() + for key, value in reference_dict.items(): + if value == old_file_url: + field_name = key + break + self.attached_to_field = field_name + if self.attached_to_field: + frappe.db.set_value(self.attached_to_doctype, self.attached_to_name, self.attached_to_field, self.file_url) + def set_folder_size(self): """Set folder size if folder""" diff --git a/frappe/public/js/frappe/ui/page.js b/frappe/public/js/frappe/ui/page.js index bf969f1566..728e9a6034 100644 --- a/frappe/public/js/frappe/ui/page.js +++ b/frappe/public/js/frappe/ui/page.js @@ -247,12 +247,27 @@ frappe.ui.Page = Class.extend({ //-- Generic --// + /* + * Add label to given drop down menu. If label, is already contained in the drop + * down menu, it will be ignored. + * @param {string} label - Text for the drop down menu + * @param {function} click - function to be called when `label` is clicked + * @param {Boolean} standard + * @param {object} parent - DOM object representing the parent of the drop down item lists + */ add_dropdown_item: function(label, click, standard, parent) { + const is_already_added = () => { + let found_lists = $(parent).find('li > a.grey-link:contains(' + label + ')'); + return found_lists.length > 0; + } + parent.parent().removeClass("hide"); var $li = $('