Browse Source

system id updated for procedure import files

master
Ubuntu 2 years ago
parent
commit
81f8309c9f
  1. 10
      smart_service/transactions/doctype/procedure/procedure.js
  2. 18
      smart_service/transactions/doctype/procedure/procedure.py

10
smart_service/transactions/doctype/procedure/procedure.js

@ -59,6 +59,16 @@ frappe.ui.form.on('Procedure', {
},
refresh: function (frm) {
if (frm.doc.procedure_details) {
frappe.call({
"method": "smart_service.transactions.doctype.procedure.procedure.update_system_id",
"args": {
"name": frm.doc.name,
},
callback: function (r) {
}
})
var url = window.location.host;
var regex = /[://]+/;
frappe.db.get_value('Fish', { name: "Fish" }, 'path', (r) => {

18
smart_service/transactions/doctype/procedure/procedure.py

@ -173,3 +173,21 @@ def procedure_name(doctype, txt, searchfield, start, page_len, filters):
def procedure_step_name(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(""" select name FROM {0}.`tabProcedure Step Name` where
(name like "%%%(txt)s%%") order by modified desc limit %(start)s, %(page_len)s """.format(current_db_name)%{'txt': txt, 'start': start, 'page_len': page_len})
@frappe.whitelist()
def update_system_id(name):
doc = frappe.get_doc("Procedure",name)
for table in doc.get("procedure_details"):
if table.content_type == "Link":
procedure = table.temp_cnt
system_mapping = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,doc.variant_mapping,doc.language),as_dict=True)
if system_mapping:
sm = system_mapping[0]['name']
sys_procedure = frappe.db.sql("""select systems,sub_systems,system_id,sub_system_id,`procedure` from {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and `procedure` = '{2}'""".format(current_db_name,sm,table.temp_cnt),as_dict=True)
if sys_procedure:
if table.temp_cnt == sys_procedure[0]['procedure']:
sys_id = doc.variant_mapping + ',' + str(sys_procedure[0]['system_id']) + ',' + str(sys_procedure[0]['sub_system_id'])
table.system_id = sys_id
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()

Loading…
Cancel
Save