From 9fcaaa97b0cf5dc861790e750c4b80e8f0489d7d Mon Sep 17 00:00:00 2001 From: Kaviraj Date: Thu, 8 Jan 2026 11:53:34 +0530 Subject: [PATCH] fix(client-script): fix redirect issue in single doctype --- .../doctype/client_script/client_script.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/frappe/custom/doctype/client_script/client_script.js b/frappe/custom/doctype/client_script/client_script.js index a09e1e72b2..1b18aa690c 100644 --- a/frappe/custom/doctype/client_script/client_script.js +++ b/frappe/custom/doctype/client_script/client_script.js @@ -8,13 +8,24 @@ frappe.ui.form.on("Client Script", { frappe.utils.highlight_pre(sample_field.$wrapper); }, refresh(frm) { - if (frm.doc.dt && frm.doc.script) { - frm.add_custom_button(__("Go to {0}", [frm.doc.dt]), () => - frappe.set_route("List", frm.doc.dt, "List") - ); - } + if (frm.doc.dt && frm.doc.script) { + frm.add_custom_button(__("Go to {0}", [frm.doc.dt]), () => { + frappe.db.get_value( + "DocType", + frm.doc.dt, + "issingle" + ).then(r => { + if (r && r.message && r.message.issingle) { + frappe.set_route("Form", frm.doc.dt); + } else { + frappe.set_route("List", frm.doc.dt); + } + }); - if (frm.doc.view == "Form") { + }); + } + +if (frm.doc.view == "Form") { frm.add_custom_button(__("Add script for Child Table"), () => { frappe.model.with_doctype(frm.doc.dt, () => { const child_tables = frappe.meta