frappe.db.sql("""update `tabSystem Mapping_Sub System` set procedure_status = "{0}" where parent = "{1}"
""".format(str(procedure),self.name))
frappe.db.commit()
# x.procedure_status = str(procedure)
@ -25,12 +26,13 @@ class SystemMapping(Document):
# x.save()
# frappe.flags.mute_messages = True
po=frappe.db.sql("""select procedure_status from {0}.`tabSystem Mapping_Sub System` where parent = '{1}'""".format(current_db_name,self.name))
# po = frappe.db.sql("""select procedure_status from {0}.`tabSystem Mapping_Sub System` where parent = "{1}";""".format(current_db_name,self.name))
frappe.db.commit()
km=frappe.db.sql("""select name,active_status from {0}.`tabKilometer Mapping` where variant_mapping = '{1}'""".format(current_db_name,self.variant_mapping),as_dict=True)
km=frappe.db.sql("""select name,active_status from {0}.`tabKilometer Mapping` where variant_mapping = "{1}";""".format(
frappe.db.sql("""update `tabSystem Mapping` set km_active_status = '{0}' where name = '{1}'
frappe.db.sql("""update `tabSystem Mapping` set km_active_status = "{0}" where name = "{1}"
""".format(status.active_status,self.name))
frappe.db.commit()
# self.km_active_status = status.active_status
@ -38,17 +40,18 @@ class SystemMapping(Document):
defvalidate(self):
###On creation of System Mapping to create Kilometer Mapping record
km=frappe.db.sql("""select name from {0}.`tabKilometer Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,self.variant_mapping,self.language),as_list=True)
km=frappe.db.sql("""select name from {0}.`tabKilometer Mapping` where variant_mapping = "{1}" and language = "{2}";""".format(current_db_name,self.variant_mapping,self.language),as_list=True)
ifnotkm:
mat=[]
km_record=frappe.new_doc("Kilometer Mapping")
km_record.variant_mapping=self.variant_mapping
km_record.language=self.language
vehicle_sk=frappe.db.sql("""select service_kilometers from {0}.`tabVehicle_SK` where parent = '{1}' order by service_kilometers""".format(current_db_name,self.vehicle),as_dict=True)
vehicle_sk=frappe.db.sql("""select service_kilometers from {0}.`tabVehicle_SK` where parent = "{1}"
assets=frappe.db.sql("""select systems,idx,active_status,system_asset,remarks from {0}.`tabSystem Mapping_System Assets` where parent = '{1}'""".format(current_db_name,self.name),as_dict=True)
assets=frappe.db.sql("""select systems,idx,active_status,system_asset,remarks from {0}.`tabSystem Mapping_System Assets`
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = "0" where parent = "{1}" and idx = "{2}";""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
ify.system_asset!=x.system_asset:
y.published="0"
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = "0" where parent = "{1}" and idx = "{2}";""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
ify.remarks!=x.remarks:
y.published="0"
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = "0" where parent = "{1}" and idx = "{2}";""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
###Mandatory fields for system mapping table
forsysteminself.get("system_sub_systems"):
ifnotsystem.procedure:
frappe.throw('Procedure to be added in row no '+str(system.idx))
values=self.get('system_sub_systems')
frappe.throw("Procedure to be added in row no "+str(system.idx))
values=self.get("system_sub_systems")
foriinrange(0,len(values)):
ifvalues[i].systems:
forxinrange(i+1,len(values)):
@ -142,7 +146,7 @@ class SystemMapping(Document):
###Method called from validation fucntion
defupdate_procedure(current_db_name,name,idx):
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,name,idx))
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = "0" where parent = "{1}" and idx = "{2}";""".format(current_db_name,name,idx))
###Updating MAT in kilometer mapping for edited mat
iftype=="Edited":
subsystem_record=frappe.db.sql("""select systems,sub_systems,mat,idx from {0}.`tabSystem Mapping_Sub System` where parent = '{1}'""".format(current_db_name,doc.name),as_dict=True)
subsystem_record=frappe.db.sql("""select systems,sub_systems,mat,idx from {0}.`tabSystem Mapping_Sub System` where parent = "{1}";""".format(current_db_name,doc.name),as_dict=True)
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)
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)
frappe.db.sql("""delete from {0}.`tabKilometer Mapping_Items` where parent = '{1}' and row_name = '{2}'""".format(current_db_name,kilometer_mapping.name,str(idx)))
frappe.db.sql("""delete from {0}.`tabKilometer Mapping_Items` where parent = "{1}" and row_name = "{2}";""".format(current_db_name,kilometer_mapping.name,str(idx)))
###Filter applied depends on last modified records and its called from system mapping js file