sys_mapping=frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language ='{2}'""".format(current_db_name,vm,lang),as_dict=True)
ifsys_mapping:
forxinsys_mapping:
doc=frappe.get_doc('System Mapping',x.name)
systems=frappe.db.sql(""" select systems FROM {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and
sys_mapping=frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,vm,lang),as_dict=True)
ifsys_mapping:
forxinsys_mapping:
doc=frappe.get_doc('System Mapping',x.name)
systems=frappe.db.sql(""" select sub_systems FROM {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and systems = '{2}' and
sys_mapping=frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,vm,lang),as_dict=True)
ifsys_mapping:
forxinsys_mapping:
doc=frappe.get_doc('System Mapping',x.name)
procedure=frappe.db.sql(""" select `procedure` FROM {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and systems = '{2}' and sub_systems = '{3}' and
sys_mapping=frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,variant_mapping,language),as_dict=True)
ifsys_mapping:
forxinsys_mapping:
doc=frappe.get_doc('System Mapping',x.name)
procedure=frappe.db.sql(""" select `procedure` FROM {0}.`tabSystem Mapping_Sub System` where parent = '{1}' and systems = '{2}' and sub_systems = '{3}'""".format(current_db_name,doc.name,systems,sub_systems))
returnprocedure
@frappe.whitelist()
defget_systemid(systems):
current_db_name=frappe.conf.get("db_name")
system=frappe.db.sql(""" select myid FROM {0}.`tabSystems` where name = '{1}'""".format(current_db_name,systems))
ifsystem:
returnsystem
@frappe.whitelist()
defget_subsystemid(systems):
current_db_name=frappe.conf.get("db_name")
system=frappe.db.sql(""" select myid FROM {0}.`tabSub Systems` where name = '{1}'""".format(current_db_name,systems))
vehicle_sk=frappe.db.sql("""select service_kilometers from {0}.`tabVehicle_SK` where parent = '{1}' order by service_kilometers""".format(current_db_name,vehicle),as_dict=True)
iftype=="Added"ortype=="New":
forservice_kminvehicle_sk:
vehicle_sk=frappe.db.sql("""select service_kilometers from {0}.`tabVehicle_SK` where parent = '{1}' order by service_kilometers""".format(current_db_name,vehicle),as_dict=True)