From 0a92007a421b8b1474ef68b5316c075a3439b397 Mon Sep 17 00:00:00 2001 From: venkataakhil Date: Mon, 26 Jun 2023 17:53:47 +0530 Subject: [PATCH] kilometer updated --- .../doctype/system_mapping/system_mapping.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/smart_service/transactions/doctype/system_mapping/system_mapping.py b/smart_service/transactions/doctype/system_mapping/system_mapping.py index 50eaf55..4f6e60f 100644 --- a/smart_service/transactions/doctype/system_mapping/system_mapping.py +++ b/smart_service/transactions/doctype/system_mapping/system_mapping.py @@ -211,13 +211,21 @@ def update_mat(doc,km,vehicle,type,idx,systems,sub_systems,mat_initial,mat_updat if type == "Added" or type == "New": 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) for service_km in vehicle_sk: - sub_system = kilometer_mapping.append("config_kilometer", {}) - sub_system.kilometer = str(service_km.service_kilometers) - sub_system.mat = str(mat) - sub_system.systems = str(systems) - sub_system.row_name = str(idx) - sub_system.sub_systems = str(sub_systems) - sub_system.applicable = km_applicable + + data = frappe.db.sql("""select name from {0}.`tabKilometer Mapping_Items` where parent = "{1}" and kilometer = "{2}" and sub_systems = "{3}" and + mat = '{4}'""".format(current_db_name,kilometer_mapping.name,service_km.service_kilometers,str(sub_systems),str(mat)),as_dict=True) + if data: + pass + else: + # if service_km.service_kilometers != km.kilometer and str(sub_systems) != km.sub_systems: + sub_system = kilometer_mapping.append("config_kilometer", {}) + sub_system.kilometer = str(service_km.service_kilometers) + sub_system.mat = str(mat) + sub_system.systems = str(systems) + sub_system.row_name = str(idx) + sub_system.sub_systems = str(sub_systems) + sub_system.applicable = km_applicable + kilometer_mapping.save() ###Delete kilometer mapping item depends on System and Sub system