fix: check if attached doctype exists (#30911)

* fix: return False if attached doctype is not found

* fix(UX): add a open url button in file form

* fix(typo): add translate to string

* fix: check if it is absolute url

* fix: return false via module not found error
This commit is contained in:
Soham Kulkarni 2025-02-04 17:43:05 +05:30 committed by GitHub
parent 68fc629389
commit 2372fd8c02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -1,5 +1,10 @@
frappe.ui.form.on("File", {
refresh: function (frm) {
frm.add_custom_button(__("View File"), () => {
if (!frappe.utils.is_url(frm.doc.file_url)) {
window.open(window.location.origin + frm.doc.file_url);
}
});
if (!frm.doc.is_folder) {
// add download button
frm.add_custom_button(__("Download"), () => frm.trigger("download"), "fa fa-download");

View file

@ -818,6 +818,8 @@ def has_permission(doc, ptype=None, user=None, debug=False):
try:
ref_doc = frappe.get_doc(attached_to_doctype, attached_to_name)
except ModuleNotFoundError:
return False
except frappe.DoesNotExistError:
frappe.clear_last_message()
return False