From d654f47b191ca99227d35eb699318ec0a9fc37ef Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Mon, 12 Jun 2023 16:43:54 +0530 Subject: [PATCH] http path get from py file --- .../doctype/procedure/procedure.js | 34 ++++++++++++------- .../doctype/procedure/procedure.py | 5 +++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/smart_service/transactions/doctype/procedure/procedure.js b/smart_service/transactions/doctype/procedure/procedure.js index e27b8a4..2923f45 100644 --- a/smart_service/transactions/doctype/procedure/procedure.js +++ b/smart_service/transactions/doctype/procedure/procedure.js @@ -69,20 +69,28 @@ frappe.ui.form.on('Procedure', { callback: function (r) { } }) - - - var url = window.location.host; - var regex = /[://]+/; - // frappe.db.get_value('Fish', { name: "Fish" }, 'path', (r) => { - frappe.db.get_single_value("Fish", "path").then((r) => { - for (var i = 0; i < frm.doc.procedure_details.length; i++) { - if (frm.doc.procedure_details[i].content && r.path && frm.doc.procedure_details[i].content_type == "Link"){// && !(frm.doc.procedure_details[i].content).includes('')){ - var x = "' + frm.doc.procedure_details[i].temp_cnt + ''; - frm.doc.procedure_details[i].content = x - } + if(frm.doc.procedure_details){ + frappe.call({ + "method": "smart_service.transactions.doctype.procedure.procedure.get_path", + "args": { + "name": frm.doc.name, + }, + callback: function (r) { + + var url = window.location.host; + var regex = /[://]+/; + // frappe.db.get_value('Fish', { name: "Fish" }, 'path', (r) => { + for (var i = 0; i < frm.doc.procedure_details.length; i++) { + if (frm.doc.procedure_details[i].content && r.message && frm.doc.procedure_details[i].content_type == "Link"){// && !(frm.doc.procedure_details[i].content).includes('')){ + var x = "' + frm.doc.procedure_details[i].temp_cnt + ''; + frm.doc.procedure_details[i].content = x + } + } + cur_frm.refresh_fields('procedure_details'); + // }) } - cur_frm.refresh_fields('procedure_details'); - }) + }) + } } select_row(frm); if (frm.doc.procedure_filter == "All") { diff --git a/smart_service/transactions/doctype/procedure/procedure.py b/smart_service/transactions/doctype/procedure/procedure.py index b4d861e..1bee137 100644 --- a/smart_service/transactions/doctype/procedure/procedure.py +++ b/smart_service/transactions/doctype/procedure/procedure.py @@ -245,3 +245,8 @@ def update_system_id(name): frappe.db.sql("""update {0}.`tabProcedure_Details` set system_id = '{1}' where parent = '{2}' and temp_cnt = '{3}'""".format( current_db_name, sys_id, doc.name, table.temp_cnt)) frappe.db.commit() +@frappe.whitelist() +def get_path(name): + path = frappe.db.get_single_value("Fish", "path") + if path: + return path \ No newline at end of file