Browse Source

Publish flow and api updation

master
Ubuntu 3 years ago
parent
commit
8b4021daa2
  1. 257
      smart_service/apis/addon_api.py
  2. 432
      smart_service/apis/master_api.py
  3. 35
      smart_service/apis/publish_api.py
  4. 1
      smart_service/apis/transaction_api.py
  5. 83
      smart_service/apis/update_validation.py
  6. 8
      smart_service/fixtures/client_script.json
  7. 114
      smart_service/fixtures/custom_docperm.json
  8. 104
      smart_service/fixtures/notification.json
  9. 170
      smart_service/fixtures/property_setter.json
  10. 65
      smart_service/fixtures/workflow.json
  11. 694
      smart_service/fixtures/workspace.json
  12. 12
      smart_service/transactions/doctype/procedure/procedure.js
  13. 9
      smart_service/transactions/doctype/procedure/procedure.py
  14. 37
      smart_service/transactions/doctype/publish/publish.js
  15. 47
      smart_service/transactions/doctype/publish/publish.json
  16. 106
      smart_service/transactions/doctype/publish/publish.py
  17. 10
      smart_service/transactions/doctype/publish_docs/publish_docs.json
  18. 7
      smart_service/transactions/doctype/system_mapping/system_mapping.js
  19. 4
      smart_service/transactions/doctype/system_mapping/system_mapping.json
  20. 68
      smart_service/transactions/doctype/system_mapping/system_mapping.py
  21. 4
      smart_service/transactions/doctype/system_mapping_sub_system/system_mapping_sub_system.json
  22. 16
      smart_service/transactions/doctype/system_mapping_system_assets/system_mapping_system_assets.json
  23. 6
      smart_service/transactions/doctype/variant_mapping/variant_mapping.js
  24. 16
      smart_service/transactions/doctype/variant_mapping/variant_mapping.py
  25. 18
      smart_service/transactions/doctype/variant_mapping_assets/variant_mapping_assets.json
  26. 345
      smart_service/transactions/report/audit_report/audit_report.js
  27. 2
      smart_service/transactions/report/audit_report/audit_report.py
  28. 71
      smart_service/transactions/report/kilometer_mapping/kilometer_mapping.js
  29. 10
      smart_service/transactions/report/kilometer_mapping/kilometer_mapping.py

257
smart_service/apis/addon_api.py

@ -1,142 +1,175 @@
import frappe
from frappe.model.document import Document
import json
import base64
import os
from frappe.utils import cstr
current_db_name = frappe.conf.get("db_name")
@frappe.whitelist()
def addon(args):
if args == "circular":
api = frappe.db.sql('''SELECT name,title,status,description,circular_image as FileUrl,valid_till as validity from {}.tabCircular WHERE valid_till >='{}' '''.format(current_db_name,frappe.utils.today()),as_dict= True)
for i in api:
if i["status"] == "Active":
i["status"] = True
else:
i["status"] = False
elif args == "user_feedback_types":
api = frappe.db.get_list(
"User Feedback_Types", fields=["name", "feedback_type", "status"]
)
for i in api:
if i["status"] == "Active":
i["status"] = True
else:
i["status"] = False
elif args == "teknet_group":
api = frappe.db.sql('''SELECT name,teknet_group_code,teknet_group_description,active_status FROM {}.`tabTeknet Group` order by teknet_group_description asc;'''.format(current_db_name),as_dict = True)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "teknet_module":
api = frappe.db.get_list(
"Teknet Module",
fields=["name", "teknet_module_name", "active_status","flvl_id"],
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "user_manual":
api = frappe.get_doc('User Manual')
else:
api = "Not found"
try:
if args == "circular":
api = frappe.db.sql('''SELECT name,title,status,description,circular_image as FileUrl,valid_till as validity from {}.tabCircular WHERE valid_till >='{}' '''.format(current_db_name,frappe.utils.today()),as_dict= True)
for i in api:
if i["status"] == "Active":
i["status"] = True
else:
i["status"] = False
elif args == "user_feedback_types":
api = frappe.db.get_list(
"User Feedback_Types", fields=["name", "feedback_type", "status"]
)
for i in api:
if i["status"] == "Active":
i["status"] = True
else:
i["status"] = False
elif args == "teknet_group":
api = frappe.db.sql('''SELECT name,teknet_group_code,teknet_group_description,active_status FROM {}.`tabTeknet Group` order by teknet_group_description asc;'''.format(current_db_name),as_dict = True)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "teknet_module":
api = frappe.db.get_list(
"Teknet Module",
fields=["name", "teknet_module_name", "active_status","flvl_id"],
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "user_manual":
api = frappe.get_doc('User Manual')
else:
api = "Not found"
except:
api = {"isSuccessful": False}
return api
@frappe.whitelist()
def bookmark(args, request):
if args == "get_bookmark":
request = json.loads(request)
usrid = request["UserID"]
lsd = request["LSD"]
api = frappe.db.get_list(
"Bookmark",
fields=["name", "vehicle_segment_id", "vehicle_id", "system_id",
"sub_system_id", "menu_id", "km_details", "variant_mapping_id"],
filters={"modified": [">", lsd], "user_id": ["=", usrid]}
)
return api
if args == "update_bookmark":
try:
try:
if args == "get_bookmark":
request = json.loads(request)
usrid = request["UserID"]
lsd = request["LSD"]
api = frappe.db.get_list(
"Bookmark",
fields=["name", "vehicle_segment_id", "vehicle_id", "system_id",
"sub_system_id", "menu_id", "km_details", "variant_mapping_id"],
filters={"modified": [">", lsd], "user_id": ["=", usrid]}
)
if args == "update_bookmark":
request = json.loads(request)
usrid = request["UserID"]
req = request["Bookmarkdetails"]
# bookmark_count=0
for i in req:
vehicle_seg_id = i["vehicle_segment_id"]
vehicle_id = i["vehicle_id"]
variant_mapping_id = i["variant_mapping_id"]
system_id = i["system_id"]
sub_system_id = i["sub_system_id"]
menu_id = i["menu_id"]
kilometer_details = i["km_details"]
is_deleted = i["IsDeleted"]
if is_deleted == False:
data = frappe.new_doc('Bookmark')
data.user_id = usrid
data.active_status = 'Active'
data.vehicle_segment_id = vehicle_seg_id
data.vehicle_id = vehicle_id
data.system_id = system_id
data.sub_system_id = sub_system_id
data.menu_id = menu_id
data.km_details = kilometer_details
data.variant_mapping_id = variant_mapping_id
data.vehicle_segment_id = i["vehicle_segment_id"]
data.vehicle_id = i["vehicle_id"]
data.system_id = i["system_id"]
data.sub_system_id = i["sub_system_id"]
data.menu_id = i["menu_id"]
data.km_details = i["km_details"]
data.variant_mapping_id = i["variant_mapping_id"]
data.insert(ignore_if_duplicate=True)
api = {"isSuccessful": True}
elif is_deleted == True:
frappe.delete_doc('Bookmark', i['name'])
# bookmark_count=bookmark_count+1
api = {"isSuccessful": True}
except:
api = {"isSuccessful": False}
return api
frappe.delete_doc("Bookmark", i["name"])
api = {"isSuccessful": True}
except:
api = {"isSuccessful": False}
return api
@frappe.whitelist()
def feedback(args, request):
if args == "get_user_feedback":
api = frappe.db.get_list(
"User Feedback",
fields=["name", "status", "feedback_type", "date",
"user_name", "attachment", "description", "date"],
)
for i in api:
if i["status"] == "Active":
i["status"] = True
else:
i["status"] = False
return api
elif args == "post_user_feedback":
try:
request = json.loads(request)
usr_fdbk = frappe.new_doc('User Feedback')
usr_fdbk.subject = request["Subject"]
usr_fdbk.feedback_type = request["FeedbackType"]
user_name = request["UserName"]
usr_id = frappe.db.get_value(
'App Users', {'user_id': user_name}, ['name'])
usr_fdbk.user_name = usr_id
usr_fdbk.status = "Open"
usr_fdbk.description = request["Description"]
usr_fdbk.date = request["Date"]
usr_fdbk.save()
return usr_fdbk.name
if args == 'get_user_feedback':
api = frappe.db.get_list(
'User Feedback',
fields=['name', 'status', 'feedback_type', 'date',
'user_name', 'attachments', 'description', 'date'],filters={'user_name':frappe.db.get_value('App Users', {'user_id': request['UserID']}, ['name'])})
for i in api:
if i['attachments'] != 0:
i['attachment'] = frappe.db.get_list('File',fields=['file_name','file_url','attached_to_name','file_size'],filters={'attached_to_name':i['name']})
if i['status'] == 'Active':
i['status'] = True
else:
i['status'] = False
return api
elif args == 'post_user_feedback':
usr_fdbk = frappe.new_doc('User Feedback')
usr_fdbk.subject = request['Subject']
usr_fdbk.feedback_type = request["FeedbackType"]
usr_fdbk.user_name = frappe.db.get_value(
"App Users", {"user_id": request["UserID"]}, ["name"])
usr_fdbk.status = "Open"
usr_fdbk.description = request["Description"]
usr_fdbk.date = request["Date"]
usr_fdbk.save()
feedback_name = usr_fdbk.name
folder = request['folder']
files_data = request['Files']
file_response= []
site_name = cstr(frappe.local.site)
for f in files_data:
for x in f:
file_name = x
file_data = f[x]
file_url = "/home/ubuntu/frappe-bench/sites/"+site_name +"/public/files/" + file_name
with open(file_url, "wb") as img:
img.write(base64.b64decode(file_data))
ret = frappe.new_doc("File")
ret.doctype = "File"
ret.attached_to_doctype = request['doctype']
ret.attached_to_name = feedback_name
ret.folder = "Home"
ret.file_name = file_name
ret.file_url = "/files/"+ file_name
ret.is_private = 0
ret.insert(ignore_permissions=True)
file_response.append(ret)
return {"isSuccessful": True,"name":usr_fdbk.name,"files":file_response}
except:
return {"isSuccessful": False}
@frappe.whitelist()
def model_hit(args, request):
if args == "model_hit":
try:
try:
if args == "model_hit":
request = json.loads(request)
UserID = request["UserID"]
AppVersion = request["AppVersion"]
@ -156,14 +189,15 @@ def model_hit(args, request):
model_hit.download_vehicle_current_version = i['DownloadVehicleCurrentVersion']
model_hit.insert(ignore_if_duplicate=True, ignore_mandatory=True)
return {"isSuccessful": True}
except:
return {"isSuccessful": False}
except:
return {"isSuccessful": False}
@frappe.whitelist()
def model_usage(args, request):
if args == "model_usage":
try:
try:
if args == "model_usage":
request = json.loads(request)
UserID = request["UserID"]
AppVersion = request["AppVersion"]
@ -188,5 +222,6 @@ def model_usage(args, request):
model_usage.language = i['Language']
model_usage.insert(ignore_if_duplicate=True, ignore_mandatory=True)
return {"isSuccessful": True}
except:
return {"isSuccessful":False}
except:
return {"isSuccessful":False}

432
smart_service/apis/master_api.py

@ -6,232 +6,236 @@ from frappe.model.document import Document
import json
from frappe.utils import cstr
current_db_name = frappe.conf.get("db_name")
@frappe.whitelist()
def masters(args, LSD):
try:
if args == "vehicle":
api = frappe.db.get_list(
"Vehicle",
fields=[
"vehicle",
"vehicle_segment",
"vehicle_segment_id",
"image",
"active_status",
"display_order",
"myid as vechile_id",
"display_order",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "variant":
api = frappe.db.get_list(
"Variant",
fields=[
"vehicle",
"vehicle_segment",
"variant",
"myid as variant_id",
"active_status",
"vehicle_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "vehicle_segment":
api = frappe.db.get_list(
"Vehicle Segment",
fields=[
"vehicle_segment",
"active_status",
"display_order",
"myid as vehicle_segment_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "transmission":
api = frappe.db.get_list(
"Transmission",
fields=[
"transmission",
"active_status",
"myid as transmission_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "drive":
api = frappe.db.get_list(
"Drive",
fields=["drive", "active_status", "myid as drive_id", "modified"],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "fuel":
api = frappe.db.get_list(
"Fuel",
fields=["fuel", "active_status", "myid as fuel_id", "modified"],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "systems":
api = frappe.db.get_list(
"Systems",
fields=[
"system_name",
"active_status",
"icon_file",
"myid as system_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "sub_systems":
api = frappe.db.get_list(
"Sub Systems",
fields=[
"sub_system_name",
"active_status",
"myid as sub_system_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
if args == "vehicle":
api = frappe.db.get_list(
"Vehicle",
fields=[
"vehicle",
"vehicle_segment",
"vehicle_segment_id",
"image",
"active_status",
"display_order",
"myid as vechile_id",
"display_order",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "variant":
api = frappe.db.get_list(
"Variant",
fields=[
"vehicle",
"vehicle_segment",
"variant",
"myid as variant_id",
"active_status",
"vehicle_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "vehicle_segment":
api = frappe.db.get_list(
"Vehicle Segment",
fields=[
"vehicle_segment",
"active_status",
"display_order",
"myid as vehicle_segment_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "transmission":
api = frappe.db.get_list(
"Transmission",
fields=[
"transmission",
"active_status",
"myid as transmission_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "drive":
api = frappe.db.get_list(
"Drive",
fields=["drive", "active_status", "myid as drive_id", "modified"],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "fuel":
api = frappe.db.get_list(
"Fuel",
fields=["fuel", "active_status", "myid as fuel_id", "modified"],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "systems":
api = frappe.db.get_list(
"Systems",
fields=[
"system_name",
"active_status",
"icon_file",
"myid as system_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "sub_systems":
api = frappe.db.get_list(
"Sub Systems",
fields=[
"sub_system_name",
"active_status",
"myid as sub_system_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "service_kilometers":
api = frappe.db.get_list(
"Service Kilometers",
fields=[
"kilometer",
"active_status",
"myid as service_kilometers_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "custom_languages":
api = frappe.db.get_list(
"Custom Languages",
fields=[
"lang_name",
"lang_code",
"active_status",
"display_order",
"myid as lang_id",
"modified",
],
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "application_menu":
api = frappe.db.get_list(
"Application Menu",
fields=[
"name",
"myid as app_menu_id",
"title",
"active_status",
],
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "translation":
api = frappe.db.get_list(
"Translation",
fields=["language", "source_text", "translated_text", "modified"],
)
elif args == "app_labels":
api = labels_json()
elif args =="app_preference":
temp_api = frappe.get_last_doc(
"App Preference",
)
api={
"application_server_url":temp_api.application_server_url,
"update_server_url":temp_api.update_server_url,
"asset_url":temp_api.asset_url,
"login_base_url":temp_api.login_base_url,
"masters_base_url":temp_api.masters_base_url,
"transactions_base_url":temp_api.transactions_base_url,
"addons_base_url":temp_api.addons_base_url,
"auto_logout_time":temp_api.auto_logout_time
}
elif args == "db":
api = frappe.conf.get("db_name")
elif args == "baseurl":
api = frappe.utils.get_url()
else:
api='No such function. Check argument: args'
elif args == "service_kilometers":
api = frappe.db.get_list(
"Service Kilometers",
fields=[
"kilometer",
"active_status",
"myid as service_kilometers_id",
"modified",
],
filters={"modified": [">", LSD]},
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "custom_languages":
api = frappe.db.get_list(
"Custom Languages",
fields=[
"lang_name",
"lang_code",
"active_status",
"display_order",
"myid as lang_id",
"modified",
],
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "application_menu":
api = frappe.db.get_list(
"Application Menu",
fields=[
"name",
"myid as app_menu_id",
"title",
"active_status",
],
)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
else:
i["active_status"] = False
elif args == "translation":
api = frappe.db.get_list(
"Translation",
fields=["language", "source_text", "translated_text", "modified"],
)
elif args == "app_labels":
api = labels_json()
elif args == "app_preference":
temp_api = frappe.get_last_doc(
"App Preference",
)
api = {
"application_server_url": temp_api.application_server_url,
"update_server_url": temp_api.update_server_url,
"asset_url": temp_api.asset_url,
"login_base_url": temp_api.login_base_url,
"masters_base_url": temp_api.masters_base_url,
"transactions_base_url": temp_api.transactions_base_url,
"addons_base_url": temp_api.addons_base_url,
"auto_logout_time": temp_api.auto_logout_time
}
else:
api = {'message': 'No such function. Check argument: args'}
except:
api = {"isSuccessful": False}
return api
def labels_json():
labels_lst = frappe.db.sql(
"""SELECT `tabApp Labels`.name as name,`tabApp Labels`.page_name as menu_type, `tabApp Labels`.english_label as element, `tabApp Labels`.language as lang, `tabApp Labels`.label as label, `tabApp Labels`.parent_app_labels as parent FROM {0}.`tabApp Labels` order by name asc""".format(current_db_name),
"""SELECT `tabApp Labels`.name as name,`tabApp Labels`.page_name as menu_type, `tabApp Labels`.english_label as element, `tabApp Labels`.language as lang, `tabApp Labels`.label as label, `tabApp Labels`.parent_app_labels as parent FROM {0}.`tabApp Labels` order by name asc""".format(
current_db_name),
as_dict=1,
)
return labels_lst
def print(inputText):
frappe.msgprint(str(inputText))

35
smart_service/apis/publish_api.py

@ -33,22 +33,25 @@ def get_parent_map(input_list, parameter):
@frappe.whitelist()
def api_procedure(args, vehicle, language, version):
x = json_grouping(args, language)
with open(base_url + "/files/json_files/%s-%s_v%s.json" % (vehicle, language, version), 'w') as f:
json.dump(x, f)
list1 = frappe.db.sql(
'''SELECT procedure_link, system, sub_system FROM %s.`tabPublish_Docs` WHERE parent='%s'; ''' % (current_db_name, args),
as_dict=True)
for d in list1:
frappe.db.sql(
"""UPDATE %s.`tabSystem Mapping_Sub System` SET procedure_status = '%s', procedure_is_published='1' where procedure_status = '%s' and `tabSystem Mapping_Sub System`.procedure='%s' and systems='%s' and sub_systems='%s' """ % (
current_db_name, 'Published', 'Publish Ready', d['procedure_link'], d['system'], d['sub_system']))
frappe.db.commit()
file_name = "/files/json_files/%s-%s_v%s.json" % (vehicle, language, version)
return file_name
try:
x = json_grouping(args, language)
with open(base_url + "/files/json_files/%s-%s_v%s.json" % (vehicle, language, version), 'w') as f:
json.dump(x, f)
list1 = frappe.db.sql(
'''SELECT procedure_link, system, sub_system FROM %s.`tabPublish_Docs` WHERE parent='%s'; ''' % (current_db_name, args),
as_dict=True)
for d in list1:
frappe.db.sql(
"""UPDATE %s.`tabSystem Mapping_Sub System` SET procedure_status = '%s', procedure_is_published='1' where procedure_status = '%s' and `tabSystem Mapping_Sub System`.procedure='%s' and systems='%s' and sub_systems='%s' """ % (
current_db_name, 'Published', 'Publish Ready', d['procedure_link'], d['system'], d['sub_system']))
frappe.db.commit()
file_name = "/files/json_files/%s-%s_v%s.json" % (vehicle, language, version)
return file_name
except:
return "Failed to save file"
def json_grouping(args, language):
docs_child = frappe.db.get_list('Publish_Docs', filters={'parent': args},

1
smart_service/apis/transaction_api.py

@ -27,5 +27,6 @@ def get_technical_manual(args):
else:
i["active_status"] = False
return manual_out
except:
return {"error":"File Not Found"}

83
smart_service/apis/update_validation.py

@ -12,45 +12,50 @@ base_url = os.path.expanduser("~") + "/frappe-bench/sites/"+site_name+"/public"
@frappe.whitelist()
def check_all_vehicle_updates(vehicle_list):
Vehicle_req_list = []
response = {}
v_list = json.loads(vehicle_list)
lang = v_list['LanguageID']
iid = v_list['InstallationId']
vehicle_data = v_list['VehicleReqList']
publish_type = frappe.db.sql(
'''SELECT publish_type FROM {}.`tabApp Device` where name='{}';'''.format(current_db_name, iid), as_list=True)
if publish_type[0][0] != None:
for v in vehicle_data:
v_id = v['Vehicle']
current_version = float(v['CurrentVersion'])
data1 = frappe.db.sql('''SELECT name,max(version) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
and publish_type='{}' and vehicle_status='Active' order by version ASC;'''.format(current_db_name, v_id,lang, publish_type[0][0]),as_dict=True)
if data1[0]['version'] != None:
if current_version == float(data1[0]['version']):
data1[0]['IsUpdateAvailable'] = "false"
Vehicle_req_list.append(data1)
else:
data = frappe.db.sql('''SELECT name,CAST(version AS DECIMAL(10,2)) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
and publish_type='{}' and vehicle_status='Active' and version > '{}' order by version ASC;'''.format(
current_db_name, v_id, lang, publish_type[0][0], current_version), as_dict=True)
data_append = []
for d in data:
d['IsUpdateAvailable'] = 'true'
d['CurrentVersion'] = int(current_version)
data_append.append(d)
Vehicle_req_list.append(data_append)
response['LanguageID'] = lang
if len(Vehicle_req_list) != 0:
response['VehicleReqList'] = Vehicle_req_list[0]
return response
try:
Vehicle_req_list = []
response = {}
v_list = json.loads(vehicle_list)
lang = v_list['LanguageID']
iid = v_list['InstallationId']
vehicle_data = v_list['VehicleReqList']
publish_type = frappe.db.sql(
'''SELECT publish_type FROM {}.`tabApp Device` where name='{}';'''.format(current_db_name, iid), as_list=True)
if publish_type[0][0] != None:
for v in vehicle_data:
v_id = v['Vehicle']
current_version = float(v['CurrentVersion'])
data1 = frappe.db.sql('''SELECT name,max(version) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
and publish_type='{}' and vehicle_status='Active' order by version ASC;'''.format(current_db_name, v_id,lang, publish_type[0][0]),as_dict=True)
if data1[0]['version'] != None:
if current_version == float(data1[0]['version']):
data1[0]['IsUpdateAvailable'] = "false"
Vehicle_req_list.append(data1)
else:
data = frappe.db.sql('''SELECT name,CAST(version AS DECIMAL(10,2)) as version,vehicle_id,language FROM {}.tabPublish where vehicle='{}' and language='{}' and publish_status='Published'
and publish_type='{}' and vehicle_status='Active' and version > '{}' order by version ASC;'''.format(
current_db_name, v_id, lang, publish_type[0][0], current_version), as_dict=True)
data_append = []
for d in data:
d['IsUpdateAvailable'] = 'true'
d['CurrentVersion'] = int(current_version)
data_append.append(d)
Vehicle_req_list.append(data_append)
response['LanguageID'] = lang
if len(Vehicle_req_list) != 0:
response['VehicleReqList'] = Vehicle_req_list[0]
return response
else:
return {'error':'No Vehicles in criteria'}
else:
return 'No Vehicles in criteria'
else:
return 'Invalid Publish Details'
return {'error':'Invalid Publish Details'}
except:
return {"isSuccessful": False}
def get_parent_map(input_list, parameter):
parentChildMap = {}
@ -282,11 +287,13 @@ def update_completed(FileName):
try:
os.remove(base_url+ FileName)
return {'isSuccessful':True}
except:
return {'isSuccessful':True}
return {'isSuccessful':False}
@frappe.whitelist()
def delete_complete(doc=None,method=None):
site_name = cstr(frappe.local.site)
base_url = os.path.expanduser("~") + "/frappe-bench/sites/"+site_name+"/public"
path = base_url+'/files/json_files/temp1/'

8
smart_service/fixtures/client_script.json

File diff suppressed because one or more lines are too long

114
smart_service/fixtures/custom_docperm.json

@ -2568,7 +2568,7 @@
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"delete": 1,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 0,
@ -3249,7 +3249,7 @@
"email": 0,
"export": 1,
"if_owner": 0,
"import": 0,
"import": 1,
"modified": "2022-01-28 18:32:42.392406",
"name": "6ba97bb393",
"parent": "Variant Mapping",
@ -3258,7 +3258,7 @@
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"report": 1,
"role": "_AppUser",
"select": 1,
"set_user_permissions": 0,
@ -3374,6 +3374,60 @@
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 0,
"export": 1,
"if_owner": 0,
"import": 0,
"modified": "2022-03-17 18:53:14.200656",
"name": "20e983d36a",
"parent": "Role Profile",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "User_Account_Manager",
"select": 1,
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 0,
"export": 1,
"if_owner": 0,
"import": 0,
"modified": "2022-03-17 18:56:43.306132",
"name": "ecc332a644",
"parent": "User Permission",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"print": 0,
"read": 1,
"report": 1,
"role": "User_Account_Manager",
"select": 1,
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
@ -3644,6 +3698,33 @@
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"modified": "2022-03-17 18:53:14.179376",
"name": "538620be4a",
"parent": "Role Profile",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"select": 0,
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
@ -4859,6 +4940,33 @@
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"modified": "2022-03-17 18:53:14.136354",
"name": "a7a22e821e",
"parent": "Role Profile",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"select": 0,
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,

104
smart_service/fixtures/notification.json

@ -11,9 +11,9 @@
"enabled": 1,
"event": "New",
"is_standard": 0,
"message": "Hello {{ doc.full_name }}\r\n<br>A new account has been created with the below details.</br>\r\n<br>Login ID: {{ doc.username }} </br>\r\n<br>Email ID: {{ doc.name }}</br>\r\n\r\n<br>Complete the registration by setting the desired role and enable the user account.</br>\r\n<br>On completion a welcome mail will be sent to the user.</br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n\r\n\r\n\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS.</br>\r\n",
"message": "<p>Hello Admin,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>A new account has been created with the below details &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>Login ID: {{ doc.username }}</p>\r\n<p>Email ID: {{ doc.name }} </p>\r\n<p>&nbsp;</p>\r\n<p>Complete the registration by setting the desired role and enable the user account.</p>\r\n<p>On completion a welcome mail will be sent to the user.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"method": null,
"modified": "2022-02-21 18:38:45.340933",
"modified": "2022-03-17 21:10:06.658616",
"module": null,
"name": "Mahindra User Creation",
"parent": null,
@ -23,14 +23,14 @@
"property_value": null,
"recipients": [
{
"bcc": "venkataakhiln@hnsonline.com",
"cc": "jecinthamarym@hnsonline.com",
"bcc": "",
"cc": "",
"condition": null,
"parent": "Mahindra User Creation",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": "email_id,user_emails",
"receiver_by_role": ""
"receiver_by_role": "User_Account_Manager"
}
],
"send_system_notification": 0,
@ -54,9 +54,9 @@
"enabled": 1,
"event": "Value Change",
"is_standard": 0,
"message": "Welcome to Smart Service CMS !!! \r\n<br>Hello {{ doc.full_name }},</br> \r\n<br>A new account has been created for you at {{ doc.creation }}.</br>\r\n<br>Your login id is: {{ doc.username }} </br>\r\n<br>Role: CMS User</br>\r\n\r\n<br>Please use Mahindra credentials for accessing your account.</br>\r\n\r\n<br>Click on the link below to access the CMS Portal.</br>\r\n<br>http://192.168.1.58:81/</br>\r\n\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin. </br>\r\n",
"message": "<p>Hello {{ doc.full_name }},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>Welcome to Guided Smart Service CMS !!! &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>A new account has been created on {{ doc.creation }}.</p>\r\n<p>Your login id is: {{ doc.username }} </p>\r\n<p>Role: CMS User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Please use Mahindra credentials for accessing your account.</br>\r\n<br>Click on the link below to access the CMS Portal.</br>\r\n<p>http://192.168.1.58:81/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"method": null,
"modified": "2022-02-22 10:40:15.721507",
"modified": "2022-03-08 10:58:11.969504",
"module": null,
"name": "Mahindra User Enabled",
"parent": null,
@ -67,7 +67,7 @@
"recipients": [
{
"bcc": null,
"cc": "jecinthamarym@hnsonline.com",
"cc": "",
"condition": null,
"parent": "Mahindra User Enabled",
"parentfield": "recipients",
@ -82,7 +82,93 @@
"sender_email": "cms@guidedsmartservice.com",
"set_property_after_alert": null,
"slack_webhook_url": null,
"subject": "Welcome to Smart Service CMS !!! ",
"subject": "Welcome to Guided Smart Service CMS !!! ",
"value_changed": "enabled"
},
{
"attach_print": 0,
"channel": "Email",
"condition": "doc.enabled==1 and doc.location==\"Mahindra\"",
"date_changed": null,
"days_in_advance": 0,
"docstatus": 0,
"doctype": "Notification",
"document_type": "User",
"enabled": 1,
"event": "Value Change",
"is_standard": 0,
"message": "<p>Hello Admin,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>The account with the below details has been successfully enabled. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<p>Login ID: {{ doc.username }}</p>\r\n<p>Email ID: {{ doc.name }} </p>\r\n<p>&nbsp;</p>\r\n<p>The user can now access the account.</p>\r\n<p>A welcome mail has been sent to the user as well.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>\r\n<br>Thanks,</br>\r\n<br>Smart Service CMS Admin</br>",
"method": null,
"modified": "2022-03-08 11:08:44.723490",
"module": null,
"name": "User Enabled",
"parent": null,
"parentfield": null,
"parenttype": null,
"print_format": null,
"property_value": null,
"recipients": [
{
"bcc": null,
"cc": null,
"condition": null,
"parent": "User Enabled",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": "email_id,user_emails",
"receiver_by_role": "User_Account_Manager"
}
],
"send_system_notification": 0,
"send_to_all_assignees": 0,
"sender": "GSS-CMS",
"sender_email": "cms@guidedsmartservice.com",
"set_property_after_alert": null,
"slack_webhook_url": null,
"subject": "User account for {{ doc.username }} successfully enabled",
"value_changed": "enabled"
},
{
"attach_print": 0,
"channel": "Email",
"condition": "doc.publish_status == \"Published\"",
"date_changed": null,
"days_in_advance": 0,
"docstatus": 0,
"doctype": "Notification",
"document_type": "Publish",
"enabled": 1,
"event": "Value Change",
"is_standard": 0,
"message": "<p>Hello Smart Service User,</p>\n<br>New <b>{{doc.publish_type}}</b> publish for <b>{{doc.vehicle}}</b> has been published successfully as <b>{{doc.name}}</b>.</br>\n<p> </p>\n<br>Thanks,</br>\n<br>Smart Service CMS Admin</br>",
"method": "smart_service.transactions.doctype.publish.publish.cal_ver",
"modified": "2022-03-17 21:09:52.741600",
"module": null,
"name": "Published Notification",
"parent": null,
"parentfield": null,
"parenttype": null,
"print_format": null,
"property_value": null,
"recipients": [
{
"bcc": null,
"cc": "",
"condition": null,
"parent": "Published Notification",
"parentfield": "recipients",
"parenttype": "Notification",
"receiver_by_document_field": "",
"receiver_by_role": "_AppUser"
}
],
"send_system_notification": 0,
"send_to_all_assignees": 0,
"sender": "GSS-CMS",
"sender_email": "cms@guidedsmartservice.com",
"set_property_after_alert": null,
"slack_webhook_url": null,
"subject": "Published : {{ doc.name }}",
"value_changed": "version"
}
]

170
smart_service/fixtures/property_setter.json

@ -91,7 +91,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "family_code",
"modified": "2021-10-29 10:54:44.614516",
"modified": "2022-03-09 18:35:49.109325",
"name": "Variant Mapping-family_code-in_list_view",
"parent": null,
"parentfield": null,
@ -108,7 +108,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "active_status",
"modified": "2021-10-29 10:54:44.541662",
"modified": "2022-03-09 18:35:49.092466",
"name": "Variant Mapping-active_status-in_list_view",
"parent": null,
"parentfield": null,
@ -125,7 +125,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "fuel",
"modified": "2021-10-29 10:54:44.625685",
"modified": "2022-03-09 18:35:49.126481",
"name": "Variant Mapping-fuel-in_list_view",
"parent": null,
"parentfield": null,
@ -142,7 +142,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "drive",
"modified": "2021-10-29 10:54:44.636879",
"modified": "2022-03-09 18:35:49.142542",
"name": "Variant Mapping-drive-in_list_view",
"parent": null,
"parentfield": null,
@ -159,7 +159,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "transmission",
"modified": "2021-10-29 10:54:44.648313",
"modified": "2022-03-09 18:35:49.158501",
"name": "Variant Mapping-transmission-in_list_view",
"parent": null,
"parentfield": null,
@ -176,7 +176,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "workflow_state",
"modified": "2021-10-29 10:54:44.553246",
"modified": "2022-03-09 18:35:49.055248",
"name": "Variant Mapping-workflow_state-in_list_view",
"parent": null,
"parentfield": null,
@ -184,7 +184,7 @@
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
"value": "0"
},
{
"default_value": null,
@ -210,7 +210,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "active_status",
"modified": "2022-02-24 12:54:45.182415",
"modified": "2022-03-09 11:05:29.625926",
"name": "Procedure-active_status-in_list_view",
"parent": null,
"parentfield": null,
@ -227,7 +227,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "fuel",
"modified": "2022-02-24 12:54:45.127510",
"modified": "2022-03-09 11:05:29.545527",
"name": "Procedure-fuel-in_list_view",
"parent": null,
"parentfield": null,
@ -244,7 +244,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "workflow_state",
"modified": "2022-02-24 12:54:45.154777",
"modified": "2022-03-09 11:05:29.593374",
"name": "Procedure-workflow_state-in_list_view",
"parent": null,
"parentfield": null,
@ -261,7 +261,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "transmission",
"modified": "2022-02-24 12:54:45.141034",
"modified": "2022-03-09 11:05:29.561039",
"name": "Procedure-transmission-in_list_view",
"parent": null,
"parentfield": null,
@ -278,7 +278,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "drive",
"modified": "2022-02-24 12:54:45.168719",
"modified": "2022-03-09 11:05:29.609482",
"name": "Procedure-drive-in_list_view",
"parent": null,
"parentfield": null,
@ -295,7 +295,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "sub_systems",
"modified": "2021-11-05 16:04:38.747620",
"modified": "2022-03-09 11:05:29.641636",
"name": "Procedure-sub_systems-in_list_view",
"parent": null,
"parentfield": null,
@ -303,7 +303,7 @@
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
"value": "1"
},
{
"default_value": null,
@ -312,7 +312,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "family_code",
"modified": "2022-02-24 12:54:45.274563",
"modified": "2022-03-09 11:05:29.508785",
"name": "Procedure-family_code-in_list_view",
"parent": null,
"parentfield": null,
@ -320,7 +320,7 @@
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
"value": "0"
},
{
"default_value": null,
@ -1621,7 +1621,7 @@
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "language",
"modified": "2022-02-24 12:54:45.289188",
"modified": "2022-03-09 11:05:29.577213",
"name": "Procedure-language-in_list_view",
"parent": null,
"parentfield": null,
@ -1681,5 +1681,141 @@
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "App Device",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "device_id",
"modified": "2022-03-04 15:50:40.150483",
"name": "App Device-device_id-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "App Device",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "publish_type",
"modified": "2022-03-04 15:50:40.167626",
"name": "App Device-publish_type-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "App Device",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "last_login",
"modified": "2022-03-04 15:50:40.183673",
"name": "App Device-last_login-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "App Device",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "active_status",
"modified": "2022-03-04 15:50:40.199328",
"name": "App Device-active_status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Email Queue",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "status",
"modified": "2022-03-16 15:06:10.506700",
"name": "Email Queue-status-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Email Queue",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "reference_doctype",
"modified": "2022-03-16 15:06:10.528451",
"name": "Email Queue-reference_doctype-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Email Queue",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "reference_name",
"modified": "2022-03-16 15:06:10.544765",
"name": "Email Queue-reference_name-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "1"
},
{
"default_value": null,
"doc_type": "Email Queue",
"docstatus": 0,
"doctype": "Property Setter",
"doctype_or_field": "DocField",
"field_name": "message",
"modified": "2022-03-16 15:06:10.464987",
"name": "Email Queue-message-in_list_view",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "in_list_view",
"property_type": "Check",
"row_name": null,
"value": "0"
}
]

65
smart_service/fixtures/workflow.json

@ -4,7 +4,7 @@
"doctype": "Workflow",
"document_type": "Procedure",
"is_active": 1,
"modified": "2022-02-18 15:42:02.086978",
"modified": "2022-03-16 13:36:06.715797",
"name": "Procedures_WF",
"override_status": 0,
"parent": null,
@ -190,17 +190,6 @@
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Publish Ready"
},
{
"action": "Reject",
"allow_self_approval": 1,
"allowed": "System Manager",
"condition": null,
"next_state": "Draft",
"parent": "Procedures_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Published"
}
],
"workflow_name": "Procedures_WF",
@ -211,13 +200,13 @@
"doctype": "Workflow",
"document_type": "Kilometer Mapping",
"is_active": 1,
"modified": "2022-01-28 15:25:51.865496",
"modified": "2022-03-16 13:36:58.134780",
"name": "Kilometer Mapping_WF",
"override_status": 0,
"parent": null,
"parentfield": null,
"parenttype": null,
"send_email_alert": 0,
"send_email_alert": 1,
"states": [
{
"allow_edit": "_Author",
@ -372,7 +361,7 @@
"allow_self_approval": 1,
"allowed": "_Approver",
"condition": null,
"next_state": "Publish Approval Pending",
"next_state": "Publish Ready",
"parent": "Kilometer Mapping_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
@ -400,60 +389,16 @@
"parenttype": "Workflow",
"state": "Approval Pending"
},
{
"action": "Approve",
"allow_self_approval": 1,
"allowed": "_Publisher",
"condition": null,
"next_state": "Publish Ready",
"parent": "Kilometer Mapping_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Publish Approval Pending"
},
{
"action": "Reject",
"allow_self_approval": 1,
"allowed": "_Publisher",
"condition": null,
"next_state": "Draft",
"parent": "Kilometer Mapping_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Publish Approval Pending"
},
{
"action": "Revoke",
"allow_self_approval": 1,
"allowed": "_Approver",
"condition": null,
"next_state": "Approval Pending",
"parent": "Kilometer Mapping_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Publish Approval Pending"
},
{
"action": "Revoke",
"allow_self_approval": 1,
"allowed": "_Publisher",
"condition": null,
"next_state": "Publish Approval Pending",
"parent": "Kilometer Mapping_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Publish Ready"
},
{
"action": "Reject",
"allow_self_approval": 1,
"allowed": "System Manager",
"condition": null,
"next_state": "Draft",
"parent": "Kilometer Mapping_WF",
"parentfield": "transitions",
"parenttype": "Workflow",
"state": "Published"
"state": "Publish Ready"
}
],
"workflow_name": "Kilometer Mapping_WF",

694
smart_service/fixtures/workspace.json

@ -2780,6 +2780,21 @@
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Translation",
"link_to": "Translation",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Masters",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
@ -3081,7 +3096,7 @@
"type": "Link"
}
],
"modified": "2022-01-28 18:44:16.457315",
"modified": "2022-03-17 18:59:51.605303",
"module": "Masters",
"name": "Masters",
"onboarding": null,
@ -3099,14 +3114,28 @@
"category": "Places",
"charts": [
{
"chart_name": "Variant mapping",
"chart_name": "Procedure",
"label": null,
"parent": "Dashboard",
"parentfield": "charts",
"parenttype": "Workspace"
},
{
"chart_name": "System Mapping",
"chart_name": "KM Mapping",
"label": null,
"parent": "Dashboard",
"parentfield": "charts",
"parenttype": "Workspace"
},
{
"chart_name": "Publish",
"label": "Publish Type",
"parent": "Dashboard",
"parentfield": "charts",
"parenttype": "Workspace"
},
{
"chart_name": "Publish Status",
"label": null,
"parent": "Dashboard",
"parentfield": "charts",
@ -3127,7 +3156,7 @@
"is_standard": 0,
"label": "Dashboard",
"links": [],
"modified": "2022-02-21 16:57:21.057162",
"modified": "2022-03-17 19:03:24.863290",
"module": "Core",
"name": "Dashboard",
"onboarding": null,
@ -3138,6 +3167,34 @@
"pin_to_top": 1,
"restrict_to_domain": null,
"shortcuts": [
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Vehicle Segment",
"link_to": "Vehicle Segment",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Service Kilometer",
"link_to": "Service Kilometers",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#47a1f5",
"doc_view": "List",
@ -3148,7 +3205,63 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Variant",
"link_to": "Variant",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Fuel",
"link_to": "Fuel",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Transmission",
"link_to": "Transmission",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Drive",
"link_to": "Drive",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
@ -3162,7 +3275,7 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
@ -3176,7 +3289,7 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
@ -3190,7 +3303,7 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
@ -3204,7 +3317,7 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
@ -3218,7 +3331,21 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": null,
"doc_view": "List",
"format": null,
"icon": null,
"label": "Kilometer Mapping",
"link_to": "Kilometer Mapping",
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
@ -3232,7 +3359,7 @@
"parent": "Dashboard",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"restrict_to_domain": "",
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
}
@ -3277,269 +3404,12 @@
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Variant Mapping",
"link_to": "Variant Mapping",
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Procedure",
"link_to": "Procedure",
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "System Mapping",
"link_to": "System Mapping",
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Kilometer Mapping",
"link_to": "Kilometer Mapping",
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Publish",
"link_to": "Publish",
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Translation Reports",
"link_to": null,
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Card Break"
}
],
"modified": "2021-11-29 10:26:07.339507",
"module": "Transactions",
"name": "Transaction",
"onboarding": null,
"parent": null,
"parentfield": null,
"parenttype": null,
"pin_to_bottom": 0,
"pin_to_top": 0,
"restrict_to_domain": null,
"shortcuts": [],
"shortcuts_label": null
},
{
"cards_label": "Elements",
"category": "Modules",
"charts": [],
"charts_label": null,
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Workspace",
"extends": "Build",
"extends_another_page": 0,
"for_user": "lincy@hnsonline.com",
"hide_custom": 0,
"icon": "tool",
"is_default": 0,
"is_standard": 0,
"label": "Build-lincy@hnsonline.com",
"links": [
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Modules",
"link_to": null,
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Card Break"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Module Def",
"link_to": "Module Def",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Workspace",
"link_to": "Workspace",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Module Onboarding",
"link_to": "Module Onboarding",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Models",
"link_to": null,
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Card Break"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "DocType",
"link_to": "DocType",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Workflow",
"link_to": "Workflow",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Views",
"link_to": null,
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Card Break"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Report",
"link_to": "Report",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Print Format",
"link_to": "Print Format",
"label": "Variant Mapping",
"link_to": "Variant Mapping",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
@ -3549,12 +3419,12 @@
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Workspace",
"link_to": "Workspace",
"label": "Procedure",
"link_to": "Procedure",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
@ -3564,12 +3434,12 @@
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Dashboard",
"link_to": "Dashboard",
"label": "System Mapping",
"link_to": "System Mapping",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
@ -3579,27 +3449,27 @@
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Scripting",
"link_to": null,
"label": "Kilometer Mapping",
"link_to": "Kilometer Mapping",
"link_type": "DocType",
"onboard": 0,
"only_for": null,
"parent": "Build-lincy@hnsonline.com",
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Card Break"
"type": "Link"
},
{
"dependencies": null,
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Client Script",
"link_to": "Client Script",
"label": "Publish",
"link_to": "Publish",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
@ -3609,20 +3479,20 @@
"hidden": 0,
"icon": null,
"is_query_report": 0,
"label": "Scheduled Job Type",
"link_to": "Scheduled Job Type",
"label": "Translation Reports",
"link_to": null,
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"parent": "Build-lincy@hnsonline.com",
"only_for": null,
"parent": "Transaction",
"parentfield": "links",
"parenttype": "Workspace",
"type": "Link"
"type": "Card Break"
}
],
"modified": "2021-11-03 10:56:35.923918",
"module": "Core",
"name": "Build-lincy@hnsonline.com",
"modified": "2021-11-29 10:26:07.339507",
"module": "Transactions",
"name": "Transaction",
"onboarding": null,
"parent": null,
"parentfield": null,
@ -3630,50 +3500,7 @@
"pin_to_bottom": 0,
"pin_to_top": 0,
"restrict_to_domain": null,
"shortcuts": [
{
"color": null,
"doc_view": "",
"format": null,
"icon": null,
"label": "DocType",
"link_to": "DocType",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": null,
"type": "DocType"
},
{
"color": null,
"doc_view": "",
"format": null,
"icon": null,
"label": "Workspace",
"link_to": "Workspace",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": null,
"type": "DocType"
},
{
"color": null,
"doc_view": "",
"format": null,
"icon": null,
"label": "Report",
"link_to": "Report",
"parent": "Build-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": null,
"type": "DocType"
}
],
"shortcuts": [],
"shortcuts_label": null
},
{
@ -4461,192 +4288,5 @@
}
],
"shortcuts_label": null
},
{
"cards_label": "",
"category": "Places",
"charts": [
{
"chart_name": "System Mapping",
"label": "System Mapping",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "charts",
"parenttype": "Workspace"
},
{
"chart_name": "Variant mapping",
"label": "Variant Mapping",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "charts",
"parenttype": "Workspace"
}
],
"charts_label": null,
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Workspace",
"extends": "Dashboard",
"extends_another_page": 0,
"for_user": "lincy@hnsonline.com",
"hide_custom": 0,
"icon": "dashboard",
"is_default": 0,
"is_standard": 0,
"label": "Dashboard-lincy@hnsonline.com",
"links": [],
"modified": "2022-02-22 10:19:29.111803",
"module": "Core",
"name": "Dashboard-lincy@hnsonline.com",
"onboarding": null,
"parent": null,
"parentfield": null,
"parenttype": null,
"pin_to_bottom": 0,
"pin_to_top": 0,
"restrict_to_domain": null,
"shortcuts": [
{
"color": "Grey",
"doc_view": "List",
"format": null,
"icon": null,
"label": "Vehicle Segment",
"link_to": "Vehicle Segment",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#47a1f5",
"doc_view": "List",
"format": null,
"icon": "setting-gear",
"label": "Vehicle",
"link_to": "Vehicle",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"format": null,
"icon": null,
"label": "Variant",
"link_to": "Variant",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#ECAD4B",
"doc_view": "List",
"format": null,
"icon": "list",
"label": "Systems",
"link_to": "Systems",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#29CD42",
"doc_view": "List",
"format": null,
"icon": "gantt",
"label": "Sub Systems",
"link_to": "Sub Systems",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#761ACB",
"doc_view": "List",
"format": null,
"icon": "solid-info",
"label": "Variant Mapping",
"link_to": "Variant Mapping",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#CB2929",
"doc_view": "List",
"format": null,
"icon": "file",
"label": "Procedure",
"link_to": "Procedure",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "#ED6396",
"doc_view": "List",
"format": null,
"icon": "branch",
"label": "System Mapping",
"link_to": "System Mapping",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "Cyan",
"doc_view": "List",
"format": "{} Open",
"icon": null,
"label": "App User Feedback",
"link_to": "User Feedback",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"format": null,
"icon": null,
"label": "Circular",
"link_to": "Circular",
"parent": "Dashboard-lincy@hnsonline.com",
"parentfield": "shortcuts",
"parenttype": "Workspace",
"restrict_to_domain": null,
"stats_filter": "{\"name\":[\"is\",\"set\"]}",
"type": "DocType"
}
],
"shortcuts_label": null
}
]

12
smart_service/transactions/doctype/procedure/procedure.js

@ -2,7 +2,15 @@
// For license information, please see license.txt
frappe.ui.form.on('Procedure', {
//refresh: function(frm) {
// }
//refresh: function(frm) {
// }
});
frappe.ui.form.on('Procedure_Details', {
file: onload,
function(frm, cdt, cdn) {
console.log("Called")
var child = locals[cdt][cdn];
console.log("Attach called" + child.file);
}
})

9
smart_service/transactions/doctype/procedure/procedure.py

@ -6,7 +6,14 @@ from frappe.model.document import Document
class Procedure(Document):
def validate(self):
pass
if self.procedure_details:
for x in self.get("procedure_details"):
if x.content_type == "File":
if not x.file:
frappe.throw("Please choose the file in row no " + str(x.idx))
if x.content_type != "File":
if not x.content:
frappe.throw("Please enter the content in row no " + str(x.idx))
@frappe.whitelist()
def get_doc_status(docname):
self = frappe.get_doc("Procedure",docname)

37
smart_service/transactions/doctype/publish/publish.js

@ -2,32 +2,17 @@
// For license information, please see license.txt
frappe.ui.form.on('Publish', {
refresh: function(frm) {
frm.set_indicator_formatter("publish_status", (doc) => {
return "green"
refresh: function(frm) {
frm.set_indicator_formatter("publish_status", (doc) => {
return "green"
})
// if(frm.doc.docstatus === 1 && frm.doc.publish_status == 'Published'){
// frm.add_custom_button(__('Global Publish'), function(){
// frappe.call({
// method: "smart_service.transactions.doctype.publish.publish.global_publish",
// args: {
// "doc": frm.doc.name,
// },
// callback:function(r){
// cur_frm.reload_doc();
// }
// });
// }).addClass("btn-warning").css({'background-color':'#f5b0cd', 'color':'black'});
// }
}
// function(frm) {
// frm.set_indicator_formatter('publish_status',
// function(doc) {
// return (doc.publish_status=="To Publish" || doc.publish_status=="Published") ? "green" : "orange"
// })
// }
},
// function(frm) {
// frm.set_indicator_formatter('publish_status',
// function(doc) {
// return (doc.publish_status=="To Publish" || doc.publish_status=="Published") ? "green" : "orange"
// })
// }
});

47
smart_service/transactions/doctype/publish/publish.json

@ -16,6 +16,7 @@
"release_description",
"version",
"published_by",
"global_publish",
"published_link",
"section_break_7",
"vehicle",
@ -23,12 +24,15 @@
"vehicle_status",
"column_break_9",
"variant_mapping",
"variant",
"variant_mapping_status",
"add_variant_mapping_to_publish",
"kilometer_mapping_section",
"kilometer_mapping",
"km_report",
"column_break_17",
"km_active_status",
"km_workflow_state",
"system_n_sub_systems",
"system_mapping",
"variant_mapping_assets",
@ -45,6 +49,7 @@
"fieldname": "release_description",
"fieldtype": "Small Text",
"label": "Publish Description",
"read_only_depends_on": "eval:doc.publish_type == \"Global\"",
"reqd": 1
},
{
@ -72,6 +77,7 @@
"in_standard_filter": 1,
"label": "Publish Type",
"options": "Internal\nGlobal",
"read_only": 1,
"reqd": 1,
"set_only_once": 1
},
@ -87,7 +93,8 @@
"fieldname": "variant_mapping",
"fieldtype": "Link",
"label": "Variant Mapping",
"options": "Variant Mapping"
"options": "Variant Mapping",
"read_only_depends_on": "eval:doc.publish_type == \"Global\""
},
{
"fieldname": "system_n_sub_systems",
@ -165,12 +172,14 @@
"read_only": 1
},
{
"depends_on": "eval:doc.variant_mapping !== undefined",
"depends_on": "eval:doc.variant_mapping !== undefined && doc.publish_type == \"Internal\"",
"fieldname": "add_variant_mapping_to_publish",
"fieldtype": "Button",
"label": "Add Variant Mapping to Publish"
"label": "Add Variant Mapping to Publish",
"read_only_depends_on": "eval:doc.publish_type == \"Global\""
},
{
"depends_on": "eval:doc.variant_mapping",
"fieldname": "kilometer_mapping_section",
"fieldtype": "Section Break",
"label": "Kilometer Mapping"
@ -187,6 +196,7 @@
"fieldtype": "Column Break"
},
{
"depends_on": "eval:doc.kilometer_mapping",
"fetch_from": "kilometer_mapping.active_status",
"fieldname": "km_active_status",
"fieldtype": "Data",
@ -194,6 +204,7 @@
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "version",
"fieldtype": "Data",
"in_standard_filter": 1,
@ -220,12 +231,40 @@
"in_list_view": 1,
"label": "Published By",
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "global_publish",
"fieldtype": "Data",
"hidden": 1,
"label": "Global Publish"
},
{
"depends_on": "eval:doc.kilometer_mapping",
"fieldname": "km_report",
"fieldtype": "Button",
"label": "Kilometer Mapping Report"
},
{
"depends_on": "eval:doc.kilometer_mapping",
"fetch_from": "kilometer_mapping.workflow_state",
"fieldname": "km_workflow_state",
"fieldtype": "Data",
"label": "Kilometer Mapping Workflow Status",
"read_only": 1
},
{
"depends_on": "eval:doc.variant_mapping",
"fieldname": "variant",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Variant"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2022-03-04 16:35:59.740494",
"modified": "2022-03-15 16:00:46.484240",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

106
smart_service/transactions/doctype/publish/publish.py

@ -8,6 +8,12 @@ current_db_name = frappe.conf.get("db_name")
class Publish(Document):
def onload(self):
current_db_name = frappe.conf.get("db_name")
if self.publish_status == "Published" and self.publish_type == "Global":
global_publish = frappe.db.sql("""select name from {0}.`tabPublish` where global_publish = '{1}'""".format(current_db_name,self.name),as_dict=True)
for global_name in global_publish:
update_mapping(self.variant_mapping,global_name.name)
u_id = frappe.get_all("User",filters={"name":frappe.session.user},fields=["username"])
if u_id:
for i in u_id:
@ -16,6 +22,10 @@ class Publish(Document):
self.published_by = str(name)
frappe.db.set_value("Publish",self.name,"published_by",str(name))
frappe.db.commit()
def on_cancel(self):
if self.publish_status == "Published":
frappe.throw('You can not <b>cancel</b> a Published Document!')
# @frappe.whitelist()
# def api_publish():
@ -43,12 +53,12 @@ class Publish(Document):
# # with open("/home/frappe_srv_01/frappe-bench/apps/smart_service/smart_service/transactions/doctype/publish/jsonData/vech.json",'w') as f:
# # json.dump(docs_child,f)
# # return json.dump(listProc)
# return docs_child
@frappe.whitelist()
def cal_ver(vehicle,lang,publish_type):
def cal_ver(vehicle,lang,publish_type,doc):
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Publish",doc)
ver = frappe.db.sql("""select max(version),publish_type from {current_db_name}.tabPublish where vehicle = '{vehi}' and language = '{lang}';"""
.format(current_db_name=current_db_name,vehi=vehicle,lang=lang))
v = 0.0
@ -66,13 +76,95 @@ def cal_ver(vehicle,lang,publish_type):
v= float(ver[0][0]) + 0.1
v =float("{:.2f}".format(v,1))
doc.version = v
frappe.db.sql("""update {0}.`tabPublish` set version = '{1}' where name = '{2}'""".format(current_db_name,v,doc.name))
frappe.db.commit()
return v
@frappe.whitelist()
def global_publish(doc):
doc = frappe.get_doc("Publish",doc)
current_db_name = frappe.conf.get("db_name")
procedure = frappe.db.sql("""select parent,name from {0}.`tabPublish_Docs` where parent = '{1}' and procedure_status='Publish Ready'""".format(current_db_name,doc.name))
if not procedure:
frappe.throw("There is no item for global publish")
max_internal_ver = frappe.db.sql('''SELECT max(version) as max_version,name as name FROM {}.tabPublish where vehicle='{}' and language ='{}' and publish_type ='Internal';'''.format(current_db_name,doc.vehicle,doc.language),as_dict=True)
for v in max_internal_ver:
if doc.version < v.max_version:
frappe.throw('Please publish Internal Publish Version ' + v.max_version + ' for ' + v.name)
publish_type = "Global"
publish_record = frappe.new_doc("Publish")
publish.language = doc.language
publish.planned_publish_date = doc.planned_publish_date
publish.publish_type = "Global"
publish.save(ignore_permissions=True)
publish_record.language = doc.language
publish_record.publish_type = "Global"
publish_record.release_description = doc.release_description
publish_record.vehicle = doc.vehicle
publish_record.vehicle_id = doc.vehicle_id
publish_record.variant_mapping = doc.variant_mapping
publish_record.variant_mapping_status = doc.variant_mapping_status
publish_record.kilometer_mapping = doc.kilometer_mapping
publish_record.km_active_status = doc.km_active_status
publish_record.variant = doc.variant
for table in doc.get('publish_documents'):
if table.procedure_status == "Publish Ready":
publish_table = publish_record.append('publish_documents',{})
publish_table.variant_mapping = table.variant_mapping
publish_table.system = table.system
publish_table.sub_system = table.sub_system
publish_table.procedure_link = table.procedure_link
publish_table.procedure_status = table.procedure_status
publish_record.asset_category = table.asset_category
publish_table.item_category = table.item_category
publish_table.variant = table.variant
for asset in doc.get('variant_mapping_assets'):
asset_table = publish_record.append('variant_mapping_assets',{})
asset_table.category = asset.category
asset_table.language = asset.language
asset_table.attach_file = asset.attach_file
asset_table.active_status = asset.active_status
publish_record.save()
doc.global_publish = publish_record.name
doc.save()
frappe.msgprint('Global Publish Created for ' + publish_record.name)
#update_mapping(doc.variant_mapping,doc.name)
@frappe.whitelist()
def old_publish(vehicle,language):
current_db_name = frappe.conf.get("db_name")
publish_record = frappe.db.sql("""select name from {0}.`tabPublish` where vehicle = '{1}' and language = '{2}' and publish_status='To Publish' and publish_type = 'Internal' and docstatus != '2'""".format(current_db_name,vehicle,language),as_list=True)
if publish_record:
return publish_record
@frappe.whitelist()
def update_mapping(variant_mapping,doc):
doc = frappe.get_doc("Publish",doc)
current_db_name = frappe.conf.get("db_name")
if doc.publish_documents:
for variant in doc.get('publish_documents'):
if variant.item_category == "Variant Mapping Assets":
vm = frappe.get_doc("Variant Mapping",variant.variant_mapping)
for v in vm.get('assets'):
if v.category == variant.asset_category:
v.published = '1'
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '1' where parent = '{1}' and category = '{2}'""".format(current_db_name,variant.variant_mapping,variant.asset_category))
frappe.db.commit()
if variant.item_category == "System Mapping":
system_mapping = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping = '{1}' and language = '{2}'""".format(current_db_name,variant.variant_mapping,doc.language),as_dict=True)
if system_mapping:
for system_map in system_mapping:
sm = frappe.get_doc("System Mapping",system_map.name)
for sys_asset in sm.get('systems_assets'):
if sys_asset.systems == variant.system:
sys_asset.published = '1'
frappe.db.sql("""update {0}.`tabSystem Mapping_System Assets` set published = '1' where parent = '{1}' and systems = '{2}'""".format(current_db_name,sm.name,variant.system))
frappe.db.commit()
for sm_item in sm.get("system_sub_systems"):
if sm_item.systems == variant.system and sm_item.sub_systems == variant.sub_system and sm_item.procedure == variant.procedure_link:
sm_item.procedure_is_published = '1'
frappe.db.sql("""update {0}.`tabSystem Mapping_Sub System` set procedure_is_published = '1' where parent = '{1}' and systems = '{2}' and sub_systems = '{3}'""".format(current_db_name,sm.name,variant.system,variant.sub_system))
frappe.db.commit()

10
smart_service/transactions/doctype/publish_docs/publish_docs.json

@ -6,6 +6,7 @@
"engine": "InnoDB",
"field_order": [
"variant_mapping",
"variant",
"system",
"sub_system",
"procedure_link",
@ -70,12 +71,19 @@
"fieldtype": "Read Only",
"in_list_view": 1,
"label": "Item Category"
},
{
"fieldname": "variant",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Fuel,Transmission,Drive",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-02-16 11:40:08.249046",
"modified": "2022-03-14 19:15:39.966713",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish_Docs",

7
smart_service/transactions/doctype/system_mapping/system_mapping.js

@ -2,7 +2,6 @@
// For license information, please see license.txt
frappe.ui.form.on('System Mapping', {
//refresh: function(frm) {
// }
});
//refresh: function(frm) {
//}
});

4
smart_service/transactions/doctype/system_mapping/system_mapping.json

@ -109,12 +109,14 @@
"label": "Config. System Level"
},
{
"allow_bulk_edit": 1,
"fieldname": "system_sub_systems",
"fieldtype": "Table",
"label": "System & Sub Systems",
"options": "System Mapping_Sub System"
},
{
"allow_bulk_edit": 1,
"fieldname": "systems_assets",
"fieldtype": "Table",
"label": "Systems Assets",
@ -169,7 +171,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-02-25 14:58:53.744459",
"modified": "2022-03-09 07:27:14.241806",
"modified_by": "Administrator",
"module": "Transactions",
"name": "System Mapping",

68
smart_service/transactions/doctype/system_mapping/system_mapping.py

@ -4,9 +4,62 @@
import frappe
from frappe.model.document import Document
current_db_name = frappe.conf.get("db_name")
class SystemMapping(Document):
def validate(self):
###If anything change to be set Published flag as 0
current_db_name = frappe.conf.get("db_name")
systems = frappe.db.sql("""select systems,sub_systems,active_status,estimated_time,idx,rts,mat,cover_image,`procedure`
from {0}.`tabSystem Mapping_Sub System` where parent = '{1}'""".format(current_db_name,self.name),as_dict=True)
if systems:
for prev_system in systems:
for cur_system in self.get("system_sub_systems"):
if prev_system.idx == cur_system.idx:
if prev_system.systems != cur_system.systems:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.sub_systems != cur_system.sub_systems:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.active_status != cur_system.active_status:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.procedure != cur_system.procedure:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.estimated_time != cur_system.estimated_time:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.rts != cur_system.rts:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.mat != cur_system.mat:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
if prev_system.cover_image != cur_system.cover_image:
cur_system.procedure_is_published = "0"
update_procedure(current_db_name,self.name,str(cur_system.idx))
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)
if assets:
for x in assets:
for y in self.get("systems_assets"):
if x.idx == y.idx and y.systems == x.systems:
if y.active_status != x.active_status:
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.commit()
if y.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.commit()
if y.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.commit()
for system in self.get("system_sub_systems"):
if not system.procedure:
frappe.throw('Procedure to be added in row no ' + str(system.idx))
values = self.get('system_sub_systems')
for i in range(0, len(values)):
if values[i].systems:
@ -15,13 +68,22 @@ class SystemMapping(Document):
frappe.throw(("Warning: Same systems (with similar sub systems and procedure) has been entered multiple times."))
if self.systems_assets:
for x in self.get("systems_assets"):
if not x.systems:
frappe.throw("Please choose the systems in row no " + str(x.idx))
if not x.system_asset:
frappe.throw("Please choose the system asset file in row no " + str(x.idx))
if not x.language:
frappe.throw("Please choose the language in row no " + str(x.idx))
if x.active_status == "In Active":
if not x.remarks:
frappe.throw("Enter the remarks for In Active status in row no " + str(x.idx))
def update_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.commit()
@frappe.whitelist()
def update_mat(doc,km,vehicle,type,sub_systems,mat_initial,mat_update,km_applicable):
current_db_name = frappe.conf.get("db_name")
mat = mat_update
kilometer_mapping = frappe.get_doc("Kilometer Mapping",km)
###Updating MAT in kilometer mapping for edited mat
@ -32,7 +94,7 @@ def update_mat(doc,km,vehicle,type,sub_systems,mat_initial,mat_update,km_applica
km.save()
###Insert MAT in kilometer mapping for added mat
if type == "Added" or type == "New":
vehicle_sk = frappe.db.sql("""select service_kilometers from `tabVehicle_SK` where parent = %s order by service_kilometers""",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)
for service_km in vehicle_sk:
sub_system = kilometer_mapping.append('config_kilometer', {})
sub_system.kilometer = str(service_km.service_kilometers)
@ -42,7 +104,7 @@ def update_mat(doc,km,vehicle,type,sub_systems,mat_initial,mat_update,km_applica
kilometer_mapping.save()
###Delete kilometer mapping item depends on Sub system
if type == "Deleted":
frappe.db.sql("""delete from `tabKilometer Mapping_Items` where parent = %s and sub_systems=%s and mat=%s""",(kilometer_mapping.name,str(sub_systems),str(mat_initial)),as_dict=True)
frappe.db.sql("""delete from {0}.`tabKilometer Mapping_Items` where parent = '{1}' and sub_systems='{2}' and mat='{3}'""".format(current_db_name,kilometer_mapping.name,str(sub_systems),str(mat_initial)),as_dict=True)
def variant(doctype, txt, searchfield, start, page_len, filters):

4
smart_service/transactions/doctype/system_mapping_sub_system/system_mapping_sub_system.json

@ -116,7 +116,7 @@
"default": "0",
"fieldname": "procedure_is_published",
"fieldtype": "Check",
"label": "Procedure is published",
"label": "System Mapping is published",
"read_only": 1
},
{
@ -128,7 +128,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-02-17 15:52:42.772944",
"modified": "2022-03-15 13:21:41.072236",
"modified_by": "Administrator",
"module": "Transactions",
"name": "System Mapping_Sub System",

16
smart_service/transactions/doctype/system_mapping_system_assets/system_mapping_system_assets.json

@ -9,7 +9,8 @@
"language",
"system_asset",
"active_status",
"remarks"
"remarks",
"published"
],
"fields": [
{
@ -17,7 +18,8 @@
"fieldtype": "Link",
"in_list_view": 1,
"label": "Systems",
"options": "Systems"
"options": "Systems",
"read_only_depends_on": "eval:doc.published == \"1\""
},
{
"fieldname": "language",
@ -26,6 +28,7 @@
"label": "Language",
"options": "Custom Languages",
"read_only": 1,
"read_only_depends_on": "eval:doc.published == \"1\"",
"reqd": 1
},
{
@ -48,12 +51,19 @@
"fieldtype": "Attach",
"in_list_view": 1,
"label": "System Asset"
},
{
"default": "0",
"fieldname": "published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-02-18 13:21:07.329144",
"modified": "2022-03-10 21:01:50.464613",
"modified_by": "Administrator",
"module": "Transactions",
"name": "System Mapping_System Assets",

6
smart_service/transactions/doctype/variant_mapping/variant_mapping.js

@ -2,6 +2,6 @@
// For license information, please see license.txt
frappe.ui.form.on('Variant Mapping', {
//refresh: function(frm) {
// }
});
//refresh: function(frm) {
// }
});

16
smart_service/transactions/doctype/variant_mapping/variant_mapping.py

@ -6,6 +6,20 @@ from frappe.model.document import Document
class VariantMapping(Document):
def validate(self):
current_db_name = frappe.conf.get("db_name")
assets = frappe.db.sql("""select category,idx,active_status,attach_file from {0}.`tabVariant Mapping_Assets` where parent = '{1}'""".format(current_db_name,self.name),as_dict=True)
for x in assets:
for y in self.get("assets"):
if x.idx == y.idx and y.category == x.category:
if y.active_status != x.active_status:
y.published = "0"
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
if y.attach_file != x.attach_file:
y.published = "0"
frappe.db.sql("""update {0}.`tabVariant Mapping_Assets` set published = '0' where parent = '{1}' and idx = '{2}'""".format(current_db_name,self.name,str(y.idx)))
frappe.db.commit()
if self.is_new():
current_db_name = frappe.conf.get("db_name")
data = frappe.db.sql("""select name from {0}.`tabVariant Mapping`
@ -16,6 +30,8 @@ class VariantMapping(Document):
frappe.throw('Variant Mapping already created as {0} for {1}'.format(data[0]['name'],self.variant))
if self.assets:
for x in self.get("assets"):
if not x.language:
frappe.throw("Please select the language in row no " + str(x.idx))
if not x.attach_file:
frappe.throw("Please select the attach file in row no " + str(x.idx))
@frappe.whitelist()

18
smart_service/transactions/doctype/variant_mapping_assets/variant_mapping_assets.json

@ -8,7 +8,8 @@
"category",
"language",
"attach_file",
"active_status"
"active_status",
"published"
],
"fields": [
{
@ -16,14 +17,16 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Category",
"options": "Tekalert\nTSB\nFSA\nTechnical Manual\nOthers"
"options": "Tekalert\nTSB\nFSA\nTechnical Manual\nOthers",
"read_only_depends_on": "eval:doc.published == \"1\""
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Language",
"options": "Custom Languages"
"options": "Custom Languages",
"read_only_depends_on": "eval:doc.published == \"1\""
},
{
"fieldname": "attach_file",
@ -37,12 +40,19 @@
"in_list_view": 1,
"label": "Active Status",
"options": "Active\nInactive"
},
{
"default": "0",
"fieldname": "published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-02-11 10:23:52.150652",
"modified": "2022-03-10 20:04:17.281847",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Variant Mapping_Assets",

345
smart_service/transactions/report/audit_report/audit_report.js

@ -3,26 +3,24 @@
/* eslint-disable */
frappe.query_reports["Audit Report"] = {
"filters": [
{
"fieldname": "variant_mapping",
"label": __("Variant Mapping"),
"fieldtype": "Link",
"options": "Variant Mapping",
get_query: function () {
return {
query: "smart_service.transactions.report.audit_report.audit_report.variant",
};
}
},
],
"formatter": function (value, row, column, data, default_formatter) {
if (value !== null && value !== 'null' && value !== undefined && value !== '' && value !== 'None') {
if (data && column.fieldname == "procedure_name") {
switch (data.indent) {
case 3:
value = `<p><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
"filters": [{
"fieldname": "variant_mapping",
"label": __("Variant Mapping"),
"fieldtype": "Link",
"options": "Variant Mapping",
get_query: function() {
return {
query: "smart_service.transactions.report.audit_report.audit_report.variant",
};
}
}, ],
"formatter": function(value, row, column, data, default_formatter) {
if (value !== null && value !== 'null' && value !== undefined && value !== '' && value !== 'None') {
if (data && column.fieldname == "procedure_name") {
switch (data.indent) {
case 3:
value = `<p><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
<g id="Procedure" transform="translate(-2581 -1954)">
<rect id="Rectangle_1705" data-name="Rectangle 1705" width="40" height="40" transform="translate(2581 1954)" fill="none"/>
<g id="Group_3451" data-name="Group 3451" transform="translate(2225.943 558.381)">
@ -34,11 +32,11 @@ frappe.query_reports["Audit Report"] = {
</g>
</g>
</svg>&nbsp;&nbsp;&nbsp;${value}</p>`
break;
break;
case 2:
if (data['type'] !== 'Asset') {
value = `<p><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
case 2:
if (data['type'] !== 'Asset') {
value = `<p><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
<g id="Sub_system" data-name="Sub system" transform="translate(-2581 -1900)">
<rect id="Rectangle_1704" data-name="Rectangle 1704" width="40" height="40" transform="translate(2581 1900)" fill="none"/>
<g id="Group_3450" data-name="Group 3450" transform="translate(3980.455 977.971)">
@ -47,12 +45,12 @@ frappe.query_reports["Audit Report"] = {
</g>
</g>
</svg>&nbsp;&nbsp;${value}</p>`
}
break;
}
break;
case 1:
if (data['type'] !== 'Asset') {
value = `<p><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
case 1:
if (data['type'] !== 'Asset') {
value = `<p><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
<g id="System" transform="translate(-2581 -1847)">
<rect id="Rectangle_1703" data-name="Rectangle 1703" width="40" height="40" transform="translate(2581 1847)" fill="none"/>
<g id="Group_3452" data-name="Group 3452" transform="translate(2543.886 1836.5)">
@ -95,14 +93,14 @@ frappe.query_reports["Audit Report"] = {
</g>
</g>
</svg>&nbsp;&nbsp;${value}</p>`
}
break;
case 0:
value = `<p><svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="18px" viewBox="0 0 24 24" width="18px" fill="#606060"><g><rect fill="none" height="24" width="24" y="0"/></g><g><g><path d="M18.92,6.01C18.72,5.42,18.16,5,17.5,5h-11C5.84,5,5.29,5.42,5.08,6.01L3,12v8c0,0.55,0.45,1,1,1h1c0.55,0,1-0.45,1-1v-1 h12v1c0,0.55,0.45,1,1,1h1c0.55,0,1-0.45,1-1v-8L18.92,6.01z M6.85,7h10.29l1.04,3H5.81L6.85,7z M19,17H5v-5h14V17z"/><circle cx="7.5" cy="14.5" r="1.5"/><circle cx="16.5" cy="14.5" r="1.5"/></g></g></svg><b>&nbsp;&nbsp;${value}</b></p>`
break;
case 4:
value = `<p>&nbsp;&nbsp;<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
}
break;
case 0:
value = `<p><svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="18px" viewBox="0 0 24 24" width="18px" fill="#606060"><g><rect fill="none" height="24" width="24" y="0"/></g><g><g><path d="M18.92,6.01C18.72,5.42,18.16,5,17.5,5h-11C5.84,5,5.29,5.42,5.08,6.01L3,12v8c0,0.55,0.45,1,1,1h1c0.55,0,1-0.45,1-1v-1 h12v1c0,0.55,0.45,1,1,1h1c0.55,0,1-0.45,1-1v-8L18.92,6.01z M6.85,7h10.29l1.04,3H5.81L6.85,7z M19,17H5v-5h14V17z"/><circle cx="7.5" cy="14.5" r="1.5"/><circle cx="16.5" cy="14.5" r="1.5"/></g></g></svg><b>&nbsp;&nbsp;${value}</b></p>`
break;
case 4:
value = `<p>&nbsp;&nbsp;<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 40 40">
<g id="Steps" transform="translate(-2579 -2008)">
<rect id="Rectangle_1706" data-name="Rectangle 1706" width="40" height="40" transform="translate(2579 2008)" fill="none"/>
<g id="Group_3453" data-name="Group 3453" transform="translate(-4.215 -1.96)">
@ -112,151 +110,134 @@ frappe.query_reports["Audit Report"] = {
</g>
</svg>&nbsp;&nbsp;&nbsp;${value}</p>`
break;
}
}
if (data && String(column.fieldname).slice(2) == '_active_status') {
switch (data.indent) {
case 2:
val = String(value).split(' / ');
//value = val[0] + " / " + `<span class="filterable indicator-pill red ellipsis"> ${val[1]} </span>`;
// value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
if (val[0] == 'A') {
value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
}
else if (val[0] == 'IA') {
value = `<span style="color:red">${val[0] + ' / ' + val[1]}</span>`;
}
break;
case 3:
column.align = 'center';
value = `<span class="filterable indicator-pill orange ellipsis"> ${value}</span>`;
break;
}
}
if (data && column.fieldname == "active_status") {
column.align = 'center';
switch (data.indent) {
case 2:
if (data.type == 'Asset') {
if (data.active_status == 'A') {
value = `<span style="color:green"> ${data.active_status} </span>`;
}
else if (data.active_status == 'IA') {
value = `<span style="color:green"> ${data.active_status} </span>`;
}
}
else {
val = String(value).split(' / ');
if (val[0] == 'A') {
value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
}
else if (val[0] == 'IA') {
value = `<span style="color:red">${val[0] + ' / ' + val[1]}</span>`;
}
// value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
}
break;
case 3:
value = `<span class="filterable indicator-pill orange ellipsis"> ${value} </span>`;
break;
case 1:
if (data.type == 'Asset') {
if (data.active_status == 'A') {
value = `<span style="color:green"> ${data.active_status} </span>`;
}
else if (data.active_status == 'IA') {
value = `<span style="color:green"> ${data.active_status} </span>`;
}
}
else {
value = `<span class="filterable indicator-pill red ellipsis"> ${value} </span>`;
}
break;
case 0:
value = `<span class="filterable indicator-pill red ellipsis"> ${value} </span>`;
break;
}
}
if (data.type == 'Asset') {
console.log(data.active_status)
}
if (data && String(column.fieldname).slice(2) === '_workflow_state') {
column.align = 'center';
value = `<span>
break;
}
}
if (data && String(column.fieldname).slice(2) == '_active_status') {
switch (data.indent) {
case 2:
val = String(value).split(' / ');
//value = val[0] + " / " + `<span class="filterable indicator-pill red ellipsis"> ${val[1]} </span>`;
// value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
if (val[0] == 'A') {
value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
} else if (val[0] == 'IA') {
value = `<span style="color:red">${val[0] + ' / ' + val[1]}</span>`;
}
break;
case 3:
column.align = 'center';
value = `<span class="filterable indicator-pill orange ellipsis"> ${value}</span>`;
break;
}
}
if (data && column.fieldname == "active_status") {
column.align = 'center';
switch (data.indent) {
case 2:
if (data.type == 'Asset') {
if (data.active_status == 'A') {
value = `<span style="color:green"> ${data.active_status} </span>`;
} else if (data.active_status == 'IA') {
value = `<span style="color:green"> ${data.active_status} </span>`;
}
} else {
val = String(value).split(' / ');
if (val[0] == 'A') {
value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
} else if (val[0] == 'IA') {
value = `<span style="color:red">${val[0] + ' / ' + val[1]}</span>`;
}
// value = `<span style="color:green">${val[0] + ' / ' + val[1]}</span>`;
}
break;
case 3:
value = `<span class="filterable indicator-pill orange ellipsis"> ${value} </span>`;
break;
case 1:
if (data.type == 'Asset') {
if (data.active_status == 'A') {
value = `<span style="color:green"> ${data.active_status} </span>`;
} else if (data.active_status == 'IA') {
value = `<span style="color:green"> ${data.active_status} </span>`;
}
} else {
value = `<span class="filterable indicator-pill red ellipsis"> ${value} </span>`;
}
break;
case 0:
value = `<span class="filterable indicator-pill red ellipsis"> ${value} </span>`;
break;
}
}
if (data.type == 'Asset') {
console.log(data.active_status)
}
if (data && String(column.fieldname).slice(2) === '_workflow_state') {
column.align = 'center';
value = `<span>
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17 7h-4v2h4c1.65 0 3 1.35 3 3s-1.35 3-3 3h-4v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5zm-6 8H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-2zm-3-4h8v2H8z"/></svg>
&nbsp&nbsp ${value} </span>`;
var langCode = String(column.fieldname).slice(0, 2);
var proc = String(data.procedure).slice(0, -2);
procValue = proc + langCode
// value = '<a href="http://' + window.location.host + '/app/procedure/' + procValue + '"' + 'target="_blank"' + '>' + value + '</a>';
column.link_onclick = "frappe.query_reports['Audit Report'].set_route(" + JSON.stringify(proc + langCode) + ")";
}
if (data && column.fieldname === 'modified' || String(column.fieldname).slice(2) === '_modified') {
column.align = 'center';
var options = { year: 'numeric', month: 'short', day: 'numeric', day: "numeric", hour: "2-digit", minute: "2-digit", second: '2-digit' };
var date = new Date(value);
value = date.toLocaleDateString("en-US", options);
}
if (data && column.fieldname === 'description') {
if (data.type === 'Asset' || data.content_type === 'File') {
value = '<a href="http://' + window.location.host + value + '"' + 'target="_blank"' + '>' + value + '</a>';
// console.log(value)
}
if (data.content_type == 'Link') {
// console.log(value)
// <a href="http://192.168.1.58:81/app/procedure/THAR.AX-0100-Air Filter Element Clean-hi">THAR.AX-0100-Air Filter Element Clean-hi</a>
var arrStr = value.split(/[<>]/);
var val1 = arrStr[1].substring(1, arrStr[1].length - 1)
// console.log(val1)
var str2 = arrStr[2]
val = '<a' + val1 + '"target="_blank">' + str2 + '</a>';
// console.log(val)
// <a onclick="window.open(this.href,'_blank');return false;" href="http://www.foracure.org.au">Some Other Site</a>
value = val
console.log(value)
// <a href="http://192.168.1.58:81/app/procedure/THAR.AX-0100-Air Filter Element Clean-hi">
}
}
}
if (data && String(column.fieldname).slice(2) == '_active_status') {
column.align = 'center';
if (value === undefined && data.indent === 2) {
if (data.type != 'Asset') {
value = "-"
}
}
}
value = default_formatter(value, row, column, data);
return value;
},
"set_route": function (data) {
// frappe.set_route("Form", "Procedure", data)
window.open("http://" + window.location.host + "/app/procedure/" + data)
},
"set_route1": function (data) {
console.log(data)
window.open("http://" + window.location.host + data)
},
"tree": true,
"name_field": "procedure_name",
"parent_field": "",
"initial_depth": 3
};
var langCode = String(column.fieldname).slice(0, 2);
var proc = String(data.procedure).slice(0, -2);
procValue = proc + langCode
// value = '<a href="http://' + window.location.host + '/app/procedure/' + procValue + '"' + 'target="_blank"' + '>' + value + '</a>';
column.link_onclick = "frappe.query_reports['Audit Report'].set_route(" + JSON.stringify(proc + langCode) + ")";
}
if (data && column.fieldname === 'modified' || String(column.fieldname).slice(2) === '_modified') {
column.align = 'center';
var options = { year: 'numeric', month: 'short', day: 'numeric', day: "numeric", hour: "2-digit", minute: "2-digit", second: '2-digit' };
var date = new Date(value);
value = date.toLocaleDateString("en-US", options);
}
if (data && column.fieldname === 'description') {
if (data.type === 'Asset' || data.content_type === 'File') {
value = '<a href="http://' + window.location.host + value + '"' + 'target="_blank"' + '>' + value + '</a>';
// console.log(value)
}
if (data.content_type == 'Link') {
var arrStr = value.split(/[<>]/);
var val1 = arrStr[1].substring(1, arrStr[1].length - 1)
var str2 = arrStr[2]
value = '<a' + val1 + '"target="_blank">' + str2 + '</a>';
}
}
}
if (data && String(column.fieldname).slice(2) == '_active_status') {
column.align = 'center';
if (value === undefined && data.indent === 2) {
if (data.type != 'Asset') {
value = "-"
}
}
}
value = default_formatter(value, row, column, data);
return value;
},
"set_route": function(data) {
// frappe.set_route("Form", "Procedure", data)
window.open("http://" + window.location.host + "/app/procedure/" + data)
},
"set_route1": function(data) {
window.open("http://" + window.location.host + data)
},
"tree": true,
"name_field": "procedure_name",
"parent_field": "",
"initial_depth": 3
};

2
smart_service/transactions/report/audit_report/audit_report.py

@ -14,8 +14,6 @@ custom_lang = frappe.db.sql(
current_db_name), as_dict=True)
activeStatusQuerycase= "case when active_status = 'Active' then 'A' else 'IA' end as active_status"
def print(strs):
frappe.msgprint(str(strs))
def execute(filters=None):
data = getData(filters)

71
smart_service/transactions/report/kilometer_mapping/kilometer_mapping.js

@ -3,35 +3,52 @@
/* eslint-disable */
frappe.query_reports["Kilometer Mapping"] = {
"filters": [
{
"fieldname": "Kilometer Mapping",
"label": __("Kilometer Mapping"),
"fieldtype": "Link",
"options": "Kilometer Mapping",
get_query: function () {
return {
query: "smart_service.transactions.report.kilometer_mapping.kilometer_mapping.variant1",
};
}
},
],
"filters": [{
"fieldname": "kilometer_mapping",
"label": __("Kilometer Mapping"),
"fieldtype": "Link",
"options": "Kilometer Mapping",
get_query: function() {
return {
query: "smart_service.transactions.report.kilometer_mapping.kilometer_mapping.variant1",
};
},
/* on_change: (frm) => {
frappe.call({
"method": "smart_service.transactions.report.kilometer_mapping.kilometer_mapping.update_wf",
"args": {
},
callback: function(r) {
var km = frappe.query_report.get_filter('workflow_state');
km.df.default = r.message;
km.refresh();
km.set_input(km.df.default);
}
});
}*/
},
// {
// "fieldname": "workflow_state",
// "label": __("Workflow State"),
/// "fieldtype": "Link",
// "options": "Kilometer Mapping",
// },
],
"formatter": function (value, row, column, data, default_formatter) {
if (data && column.fieldname !== "sub_systems" && column.fieldname !== 'mat') {
column.align = 'center';
if (value === true) {
value = `<p>
"formatter": function(value, row, column, data, default_formatter) {
if (data && column.fieldname !== "sub_systems" && column.fieldname !== 'mat') {
column.align = 'center';
if (value === true) {
value = `<p>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>
</p>`
}
else {
value = `<p>
} else {
value = `<p>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
</p>`
}
}
value = default_formatter(value, row, column, data);
return value;
}
};
}
}
value = default_formatter(value, row, column, data);
return value;
}
};

10
smart_service/transactions/report/kilometer_mapping/kilometer_mapping.py

@ -17,8 +17,8 @@ def get_data(filters):
final_append = []
kilometer_mapping = []
if len(filters) > 0:
data = frappe.db.sql('''select sub_systems,mat, group_concat(distinct(kilometer)) as kilometer from {}.`tabKilometer Mapping_Items` where parent Like '{}' and applicable='1' group by sub_systems order by length(kilometer), kilometer asc; '''.format(current_db_name,filters['Kilometer Mapping']),as_dict = True)
kilometer_mapping = frappe.db.sql('''select distinct(kilometer) from {}.`tabKilometer Mapping_Items` where parent ='{}' order by length(kilometer),kilometer asc;'''.format(current_db_name,filters['Kilometer Mapping']), as_list = True)
data = frappe.db.sql('''select sub_systems,mat, group_concat(distinct(kilometer)) as kilometer from {}.`tabKilometer Mapping_Items` where parent Like '{}' and applicable='1' group by sub_systems order by length(kilometer), kilometer asc; '''.format(current_db_name,filters['kilometer_mapping']),as_dict = True)
kilometer_mapping = frappe.db.sql('''select distinct(kilometer) from {}.`tabKilometer Mapping_Items` where parent ='{}' order by length(kilometer),kilometer asc;'''.format(current_db_name,filters['kilometer_mapping']), as_list = True)
for i in data:
kilo_data = i['kilometer']
list1 = list(map(str, kilo_data.split(',')))
@ -68,3 +68,9 @@ def variant1(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(""" select name,family_code,fuel,transmission,active_status
FROM {0}.`tabKilometer Mapping` where
(active_status like "%%%(txt)s%%" or name like "%%%(txt)s%%" or family_code like "%%%(txt)s%%" or fuel like "%%%(txt)s%%" or transmission 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_wf(doc):
#km = filters.get('kilometer_mapping')
wf= frappe.db.get_value('Kilometer Mapping', km, 'workflow_state')
return wf
Loading…
Cancel
Save