Browse Source

procedure link validation

master
Ubuntu 3 years ago
parent
commit
0c9b94e6e7
  1. 206
      smart_service/fixtures/client_script.json
  2. 16
      smart_service/transactions/doctype/procedure/procedure.json
  3. 112
      smart_service/transactions/doctype/procedure/procedure.py
  4. 11
      smart_service/transactions/doctype/procedure_details/procedure_details.json
  5. 3
      smart_service/transactions/doctype/procedure_step_name/procedure_step_name.json
  6. 17
      smart_service/transactions/doctype/system_mapping/system_mapping.py

206
smart_service/fixtures/client_script.json

File diff suppressed because one or more lines are too long

16
smart_service/transactions/doctype/procedure/procedure.json

@ -137,14 +137,6 @@
"reqd": 1, "reqd": 1,
"set_only_once": 1 "set_only_once": 1
}, },
{
"allow_bulk_edit": 1,
"fieldname": "procedure_details",
"fieldtype": "Table",
"label": "Procedure_Details",
"options": "Procedure_Details",
"read_only_depends_on": "eval:doc.workflow_state == \"Publish Ready\""
},
{ {
"fetch_from": "variant_mapping.vehicle", "fetch_from": "variant_mapping.vehicle",
"fieldname": "vehicle", "fieldname": "vehicle",
@ -228,11 +220,17 @@
"fieldname": "html_reference", "fieldname": "html_reference",
"fieldtype": "HTML", "fieldtype": "HTML",
"label": "HTML Reference" "label": "HTML Reference"
},
{
"fieldname": "procedure_details",
"fieldtype": "Table",
"label": "Procedure Details",
"options": "Procedure Details Table"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2022-03-04 11:39:52.723922", "modified": "2022-04-08 16:05:21.577889",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Procedure", "name": "Procedure",

112
smart_service/transactions/doctype/procedure/procedure.py

@ -3,6 +3,7 @@
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
import frappe,json
class Procedure(Document): class Procedure(Document):
def validate(self): def validate(self):
@ -54,4 +55,115 @@ def drive(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(""" select name FROM {0}.tabDrive where return frappe.db.sql(""" select name FROM {0}.tabDrive 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}) (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 get_variant(doctype, txt, searchfield, start, page_len, filters):
current_db_name = frappe.conf.get("db_name")
if not filters:
return []
filters = frappe._dict(filters)
vm = filters.get('variant_mapping')
lang = filters.get('language')
if vm:
vehicle = frappe.db.get_value('Variant Mapping', vm, 'vehicle')
variant = frappe.db.sql("""select name,family_code,fuel,transmission,drive,active_status FROM {0}.`tabVariant Mapping` where vehicle = '{1}' and
(name like "%%%(txt)s%%" or active_status like "%%%(txt)s%%" or drive like "%%%(txt)s%%" or family_code like "%%%(txt)s%%" or fuel like "%%%(txt)s%%" or transmission like "%%%(txt)s%%") group by name limit %(start)s, %(page_len)s """.format(current_db_name,vehicle)%{'txt': txt, 'start': start, 'page_len': page_len})
if variant:
return variant
else:
return []
else:
return []
@frappe.whitelist()
def get_systems(doctype, txt, searchfield, start, page_len, filters):
current_db_name = frappe.conf.get("db_name")
if not filters:
return []
filters = frappe._dict(filters)
vm = filters.get('variant_mapping')
lang = filters.get('language')
if vm:
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)
if sys_mapping:
for x in sys_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
(systems like "%%%(txt)s%%") group by systems limit %(start)s, %(page_len)s """.format(current_db_name,doc.name)%{'txt': txt, 'start': start, 'page_len': page_len},as_list=True)
if systems:
return systems
else:
return []
else:
return []
else:
return []
@frappe.whitelist()
def get_subsystems(doctype, txt, searchfield, start, page_len, filters):
current_db_name = frappe.conf.get("db_name")
if not filters:
return []
filters = frappe._dict(filters)
vm = filters.get('variant_mapping')
systems = filters.get('systems')
lang = filters.get('language')
if vm:
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)
if sys_mapping:
for x in sys_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
(sub_systems like "%%%(txt)s%%") group by sub_systems limit %(start)s, %(page_len)s """.format(current_db_name,doc.name,systems)%{'txt': txt, 'start': start, 'page_len': page_len})
if systems:
return systems
else:
return []
else:
return []
else:
return []
@frappe.whitelist()
def get_procedure(doctype, txt, searchfield, start, page_len, filters):
current_db_name = frappe.conf.get("db_name")
if not filters:
return []
filters = frappe._dict(filters)
vm = filters.get('variant_mapping')
systems = filters.get('systems')
sub_systems = filters.get('sub_systems')
lang = filters.get('language')
if vm:
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)
if sys_mapping:
for x in sys_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
(`procedure` like "%%%(txt)s%%") group by `procedure` limit %(start)s, %(page_len)s """.format(current_db_name,doc.name,systems,sub_systems)%{'txt': txt, 'start': start, 'page_len': page_len})
if procedure:
return procedure
else:
return []
else:
return []
else:
return []
@frappe.whitelist()
def get_procedures(variant_mapping,systems,sub_systems,language):
current_db_name = frappe.conf.get("db_name")
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)
if sys_mapping:
for x in sys_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))
return procedure
@frappe.whitelist()
def get_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))
if system:
return system
@frappe.whitelist()
def get_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))
if system:
return system

11
smart_service/transactions/doctype/procedure_details/procedure_details.json

@ -11,7 +11,8 @@
"content", "content",
"temp_cnt", "temp_cnt",
"file", "file",
"preview" "preview",
"system_id"
], ],
"fields": [ "fields": [
{ {
@ -69,12 +70,18 @@
"hidden": 1, "hidden": 1,
"label": "Temp Cnt", "label": "Temp Cnt",
"options": "URL" "options": "URL"
},
{
"fieldname": "system_id",
"fieldtype": "Data",
"hidden": 1,
"label": "System ID"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2022-02-25 12:35:29.270218", "modified": "2022-04-08 22:21:10.666175",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Procedure_Details", "name": "Procedure_Details",

3
smart_service/transactions/doctype/procedure_step_name/procedure_step_name.json

@ -1,6 +1,7 @@
{ {
"actions": [], "actions": [],
"allow_import": 1, "allow_import": 1,
"allow_rename": 1,
"autoname": "format:{step_name}", "autoname": "format:{step_name}",
"creation": "2021-12-03 09:42:59.565222", "creation": "2021-12-03 09:42:59.565222",
"doctype": "DocType", "doctype": "DocType",
@ -23,7 +24,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2021-12-03 12:23:23.239225", "modified": "2022-04-05 16:11:23.912047",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Procedure Step Name", "name": "Procedure Step Name",

17
smart_service/transactions/doctype/system_mapping/system_mapping.py

@ -93,14 +93,15 @@ def update_mat(doc,km,vehicle,type,sub_systems,mat_initial,mat_update,km_applica
km.mat = str(mat) km.mat = str(mat)
km.save() km.save()
###Insert MAT in kilometer mapping for added mat ###Insert MAT in kilometer mapping for added mat
if type == "Added" or type == "New": if mat:
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) if type == "Added" or type == "New":
for service_km in vehicle_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)
sub_system = kilometer_mapping.append('config_kilometer', {}) for service_km in vehicle_sk:
sub_system.kilometer = str(service_km.service_kilometers) sub_system = kilometer_mapping.append('config_kilometer', {})
sub_system.mat = str(mat) sub_system.kilometer = str(service_km.service_kilometers)
sub_system.sub_systems = str(sub_systems) sub_system.mat = str(mat)
sub_system.applicable = km_applicable sub_system.sub_systems = str(sub_systems)
sub_system.applicable = km_applicable
kilometer_mapping.save() kilometer_mapping.save()
###Delete kilometer mapping item depends on Sub system ###Delete kilometer mapping item depends on Sub system
if type == "Deleted": if type == "Deleted":

Loading…
Cancel
Save