Browse Source

QWIk, MST with publish modules

version2
venkataakhil 1 year ago
parent
commit
07d419239b
  1. 6
      smart_service/apis/master_api.py
  2. 117
      smart_service/apis/v2/master.py
  3. 22
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  4. 7
      smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json
  5. 24
      smart_service/phase_2/doctype/instructions/instructions.json
  6. 30
      smart_service/phase_2/doctype/qwik_service/qwik_service.js
  7. 19
      smart_service/phase_2/doctype/qwik_service/qwik_service.json
  8. 4
      smart_service/phase_2/doctype/qwik_service/qwik_service.py
  9. 29
      smart_service/phase_2/doctype/qwik_service_publish_data/qwik_service_publish_data.json
  10. 0
      smart_service/phase_2/doctype/qwik_service_publish_docs/__init__.py
  11. 77
      smart_service/phase_2/doctype/qwik_service_publish_docs/qwik_service_publish_docs.json
  12. 8
      smart_service/phase_2/doctype/qwik_service_publish_docs/qwik_service_publish_docs.py
  13. 123
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
  14. 37
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.json
  15. 6
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.py
  16. 0
      smart_service/phase_2/doctype/special_tool_publish_data/__init__.py
  17. 74
      smart_service/phase_2/doctype/special_tool_publish_data/special_tool_publish_data.json
  18. 8
      smart_service/phase_2/doctype/special_tool_publish_data/special_tool_publish_data.py
  19. 0
      smart_service/phase_2/doctype/special_tool_publish_docs/__init__.py
  20. 74
      smart_service/phase_2/doctype/special_tool_publish_docs/special_tool_publish_docs.json
  21. 8
      smart_service/phase_2/doctype/special_tool_publish_docs/special_tool_publish_docs.py
  22. 0
      smart_service/phase_2/doctype/teb_instructions/__init__.py
  23. 30
      smart_service/phase_2/doctype/teb_instructions/teb_instructions.json
  24. 8
      smart_service/phase_2/doctype/teb_instructions/teb_instructions.py
  25. 7
      smart_service/public/js/common_fun.js
  26. 1
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js
  27. 3
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json
  28. 422
      smart_service/transactions/doctype/publish/publish.js
  29. 52
      smart_service/transactions/doctype/publish/publish.json
  30. 376
      smart_service/transactions/doctype/publish/publish.py

6
smart_service/apis/master_api.py

@ -280,6 +280,8 @@ def masters(args=None, LSD=None, iid=None):
temp_api = frappe.get_doc(
"App Preference",
)
time_val = datetime.datetime.strptime(
temp_api.auto_logout_time, '%H:%M:%S')
api = {
"application_server_url": temp_api.application_server_url,
"update_server_url": temp_api.update_server_url,
@ -288,7 +290,7 @@ def masters(args=None, LSD=None, iid=None):
"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
"auto_logout_time": time_val.strftime('%H:%M:%S.%f')
}
else:
@ -346,7 +348,7 @@ def old_variant(LSD, language):
@frappe.whitelist(methods=['POST'])
def variant(LSD, language,iid = None):
def variant(LSD, language, iid=None):
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
try:

117
smart_service/apis/v2/master.py

@ -18,7 +18,6 @@ current_db_name = frappe.conf.get("db_name")
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_role_mapping():
req = json.loads(frappe.request.data)
try:
lsdt = req['lsdt']
if lsdt != '':
@ -31,6 +30,7 @@ def get_role_mapping():
except Exception as e:
frappe.local.response['http_status_code'] = 403
return {"status": 0, "error": e}
data = {}
try:
module_details = frappe.db.sql(f"""select module_name,active_status,my_id,display_order,modified from `tabModule Master`
@ -96,32 +96,37 @@ def get_feature_finder(vehicle, variant, language):
for f in feature_finder_details:
f['disclaimer'] = frappe.db.sql(f'''
SELECT name,content,idx as display_order FROM `tabFeature Finder Disclaimer`
where parent = '{str(f['vehicle'])+ str('-')+ str(f['feature_name']) +str('-')+str(f['language'])}';
where parent = '{str(f['vehicle'])+ str('-')+ str(f['feature_name']) +str('-')+str(f['language'])}'
order by display_order;
''', as_dict=1)
sop_images = frappe.db.sql(f""" select image,idx as display_order from `tabFeature Finder Images` where
parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
parent = '{f['name']}' and feature_type ='SOP' order by display_order;""", as_dict=1)
sop_content = frappe.db.sql(f"""select content,idx as display_order from `tabFeature Finder Content`
where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
where parent = '{f['name']}' and feature_type ='SOP' order by display_order;""", as_dict=1)
sop_specification = frappe.db.sql(f"""select specification,value,idx as display_order from `tabFeature Finder Specification`
where parent = '{f['name']}' and feature_type ='SOP';""", as_dict=1)
where parent = '{f['name']}' and feature_type ='SOP' order by display_order;""", as_dict=1)
f['sop'] = {'content': sop_content, 'images': sop_images,
'specificaton': sop_specification, 'sop_name': f['sop_name']}
post_vin_data = frappe.db.sql(f'''select name,idx as display_order,post_vin_cutoff_name,post_vin_cutoff_id
from `tabPost Vin Cutoff ID` where parent = '{f['name']}';''', as_dict=1)
from `tabPost Vin Cutoff ID` where parent = '{f['name']}' order by display_order;''', as_dict=1)
for p in post_vin_data:
vin_content = frappe.db.sql(f"""select content,idx as display_order from `tabFeature Finder Content`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
where parent = '{f['name']}'
and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}'
order by display_order;""", as_dict=1)
vin_images = frappe.db.sql(f""" select image,idx as display_order from `tabFeature Finder Images` where
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}'
order by display_order;""", as_dict=1)
vin_specification = frappe.db.sql(f"""select specification,value,idx as display_order from `tabFeature Finder Specification`
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}';""", as_dict=1)
where parent = '{f['name']}' and post_vin_cutoff_name ='{p['post_vin_cutoff_name']}'
order by display_order;""", as_dict=1)
p['content'] = vin_content
p['images'] = vin_images
p['specificaton'] = vin_specification
@ -164,14 +169,25 @@ def new_publish():
elif module == 'Repair/Service Check Sheet':
flag, data = get_repair_service_mapping(vehicle, language)
elif module == 'QWIK Service':
flag, data = get_qwik_service(variant, language)
elif module == 'Training Information':
flag, data = get_training_information(vehicle, language)
# flag, data = get_training_information(vehicle, language)
pass
elif module == "Mahindra Special Tool Information":
elif module == 'Special Tool Information':
flag, data = get_special_tool_information(vehicle)
elif module == "Qwik Service":
flag, data = get_qwik_service(variant, language)
elif module == 'PDI Inspection':
pass
elif module == 'Torque Information NM':
pass
else:
flag = False
data = 'No Module found'
if flag:
return {'status': 1, 'error': None, 'data': data}
@ -208,22 +224,37 @@ def new_publish1():
with open(BASE_PATH + str(vehicle) + '-feature_finder.json') as outfile:
data = json.load(outfile)
data = data['data']
filter_json = filter_publish_json(data,variant)
data = filter_json
elif module == 'Repair/Service Check Sheet':
with open(BASE_PATH + str(vehicle) + '-repair_check_sheet.json') as outfile:
data = json.load(outfile)
data = data['data']
filter_json = filter_publish_json(data,variant)
data = filter_json
elif module == 'Qwik Service':
elif module == 'QWIK Service':
with open(BASE_PATH + str(vehicle) + '-qwik_service.json') as outfile:
data = json.load(outfile)
data = data['data']
filter_json = filter_publish_json(data,variant)
data = filter_json
elif module == 'Training Information':
pass
# elif module == 'Training Information':
# flag, data = get_training_information(vehicle, language)
elif module == 'Mahindra Special Tool Information':
pass
elif module == 'PDI Inspection':
pass
elif module == 'Torque Information NM':
pass
else:
data = 'No Module found'
# elif module == "Mahindra Special Tool Information":
# flag, data = get_special_tool_information(vehicle)
return {'status': 1, 'error': None, 'data': data}
except Exception as e:
@ -234,29 +265,47 @@ def new_publish1():
@frappe.whitelist(methods=['POST'], allow_guest=1)
def get_special_tool_information(vehicle):
try:
special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order,
my_id,keywords from `tabSpecial Tool Information`
where vehicle="{vehicle}";''', as_dict=1)
for s in special_tool_details:
s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status
from `tabMST Information Assets` where parent = '{s['name']}' order by display_order;''', as_dict=1)
return True, special_tool_details
# special_tool_details = frappe.db.sql(f''' select name,vehicle,category,sub_category,display_order,
# my_id,keywords from `tabSpecial Tool Information`
# where vehicle="{vehicle}";''', as_dict=1)
special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type,category,tool_name,aggregate_name,aggregate_image,
pdf,keywords,display_order,my_id,active_status from `tabSpecial Tool Information`
where vehicle= '%s' ;''' % (vehicle), as_dict=1)
for s in special_tool_information:
# s['tool_usage_content'] = frappe.db.sql(f'''select idx as 'display_order',image,content,video,asset_type,active_status
# from `tabMST Information Assets` where parent = '{s['name']}' order by display_order;''', as_dict=1)
s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name,content_type,content,attach_file
from `tabInstructions` where parent = '%s' order by display_order;''' % (s['name']), as_dict=1)
return True, special_tool_information
except Exception as e:
return False, e
@frappe.whitelist(methods=['POST'], allow_guest=1)
# @frappe.whitelist(methods=['POST'], allow_guest=1)
def get_qwik_service(variant, language):
try:
qwik_service_details = frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status,
pdf,display_order,keywords,my_id from `tabQwik Service` where variant='%s' &&
language='%s';''' % (variant, language), as_dict=1)
for q in qwik_service_details:
q['content'] = frappe.db.sql('''select idx as 'display_order',content_type,content from `tabQwik Service Content`
where parent='%s';''' % (q['name']), as_dict=1)
q['pre_work'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where parent='%s'
&& content_type = 'Pre-work' order by display_order;''' % (q['name']), as_dict=1)
q['consumables'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Consumables' order by display_order;''' % (q['name']), as_dict=1)
q['tools'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Tools' order by display_order;''' % (q['name']), as_dict=1)
for p in qwik_service_details:
p['qwik_procedure'] = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s';''' % (p['name']), as_dict=1)
# p['qwik_procedure'] = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
# where parent ='%s';''' % (p['name']), as_dict=1)
LHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'LHS';''' % (p['name']), as_dict=1)
RHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'RHS';''' % (p['name']), as_dict=1)
p['qwik_procedure'] = {'LHS': LHS, 'RHS': RHS}
return True, qwik_service_details
except Exception as e:
return False, e
@ -293,3 +342,11 @@ def update_publish_mapping(vehicle, variant, language, module):
doc.repairservice_check_sheet = 1
doc.save()
return 1
def filter_publish_json(src_json,filter_cond):
try:
filtered_json = [src_json.get(filter_cond, None) for d in src_json]
return filtered_json[0]
except Exception as e:
frappe.throw(str(e))

22
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -132,8 +132,8 @@ frappe.ui.form.on('Feature Finder', {
spec_id_dis.push(this.id);
});
if(spec_id_dis && spec_id_dis.length>0){
set_display_order_child("Feature Finder Specification", spec_id_dis)
console.log(spec_id_dis,"---spec_id_dis")
set_display_order_child("Feature Finder Specification", spec_id_dis,frm)
}
$('.feature_imgbl').find('table > tbody > tr').each(function (index, tr) {
@ -141,14 +141,14 @@ frappe.ui.form.on('Feature Finder', {
});
if(image_id_dis && image_id_dis.length>0){
set_display_order_child("Feature Finder Images", image_id_dis)
set_display_order_child("Feature Finder Images", image_id_dis,frm)
}
$('.feature_contbl').find('table > tbody > tr').each(function (index, tr) {
cont_id_dis.push(this.id);
});
if(cont_id_dis && cont_id_dis.length>0){
set_display_order_child("Feature Finder Content", cont_id_dis)
set_display_order_child("Feature Finder Content", cont_id_dis,frm)
}
})
@ -202,7 +202,7 @@ frappe.ui.form.on('Feature Finder', {
frm.reload_doc()
}
});
function set_display_order_child(doctype_name, values) {
function set_display_order_child(doctype_name, values,frm) {
if (values.length>0){
frappe.call({
method: "smart_service.phase_2.doctype.feature_finder.feature_finder.set_display_order",
@ -211,9 +211,9 @@ function set_display_order_child(doctype_name, values) {
values: values
},
callback: function (r) {
console.log(r.message,"---rmessage")
if (r.message) {
// console.log(r.message,"---r.message")
cur_frm.refresh()
frm.refresh()
}
}
})
@ -627,7 +627,7 @@ function custom_tab_html(frm) {
$('.specification_bl').find('table > tbody > tr').each(function (index, tr) {
spec_id_dis.push(this.id);
});
set_display_order_child("Feature Finder Specification", spec_id_dis)
set_display_order_child("Feature Finder Specification", spec_id_dis,frm)
})
})
@ -637,7 +637,7 @@ function custom_tab_html(frm) {
$('.feature_imgbl').find('table > tbody > tr').each(function (index, tr) {
image_id_dis.push(this.id);
});
set_display_order_child("Feature Finder Images", image_id_dis)
set_display_order_child("Feature Finder Images", image_id_dis,frm)
})
})
@ -647,13 +647,13 @@ function custom_tab_html(frm) {
$('.feature_contbl').find('table > tbody > tr').each(function (index, tr) {
cont_id_dis.push(this.id);
});
set_display_order_child("Feature Finder Content", cont_id_dis)
set_display_order_child("Feature Finder Content", cont_id_dis,frm)
})
})
function set_display_order_child(doctype_name, values) {
function set_display_order_child(doctype_name, values,frm) {
frappe.call({
method: "smart_service.phase_2.doctype.feature_finder.feature_finder.set_display_order",
args: {

7
smart_service/phase_2/doctype/feature_finder_master/feature_finder_master.json

@ -1,6 +1,4 @@
{
"_comments": "[]",
"_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{feature_name}-{language}",
@ -38,7 +36,8 @@
"fieldname": "feature_finder_disclaimer",
"fieldtype": "Table",
"label": "Feature Finder Disclaimer",
"options": "Feature Finder Disclaimer"
"options": "Feature Finder Disclaimer",
"reqd": 1
},
{
"fieldname": "column_break_5ksna",
@ -77,7 +76,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-04 17:44:36.498919",
"modified": "2023-09-26 10:50:41.276397",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder Master",

24
smart_service/phase_2/doctype/instructions/instructions.json

@ -9,21 +9,21 @@
"step_name",
"content_type",
"content",
"imagevideo",
"pdf"
"attach_file"
],
"fields": [
{
"fieldname": "step_name",
"fieldtype": "Link",
"label": "Step Name",
"options": "Instructions Step Name"
"fieldtype": "Data",
"label": "Step Name"
},
{
"fieldname": "content_type",
"fieldtype": "Select",
"label": "Content Type",
"options": "Content\nImage\nVideo\nPDF"
"options": "Heading\nDescription\nCaution\nWarning\nImage\nVideo\nPDF",
"read_only_depends_on": "// eval:doc.content_type == 'PDF'",
"set_only_once": 1
},
{
"fieldname": "content",
@ -31,21 +31,15 @@
"label": "Content"
},
{
"depends_on": "eval:doc.instructions!='Content'",
"fieldname": "imagevideo",
"fieldtype": "Attach",
"label": "Image/Video"
},
{
"fieldname": "pdf",
"fieldname": "attach_file",
"fieldtype": "Attach",
"label": "PDF"
"label": "Attach File"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-21 18:30:15.606987",
"modified": "2023-09-26 11:27:34.468690",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Instructions",

30
smart_service/phase_2/doctype/qwik_service/qwik_service.js

@ -67,20 +67,20 @@ frappe.ui.form.on('Qwik Service', {
vehicle: function(frm){
set_display_order(frm)
},
variant: function (frm) {
frappe.call({
method: "smart_service.phase_2.doctype.qwik_service.qwik_service.get_kilometer",
args: {
vehicle: frm.doc.vehicle,
service_kilometers: frm.doc.service_kilometers
},
callback: function (r) {
console.log(r.message)
frm.set_df_property('kilometers', 'options', r.message);
frm.refresh_field('kilometers')
}
})
},
// variant: function (frm) {
// frappe.call({
// method: "smart_service.phase_2.doctype.qwik_service.qwik_service.get_kilometer",
// args: {
// vehicle: frm.doc.vehicle,
// service_kilometers: frm.doc.service_kilometers
// },
// callback: function (r) {
// console.log(r.message)
// frm.set_df_property('kilometers', 'options', r.message);
// frm.refresh_field('kilometers')
// }
// })
// },
});
function custom_tab_html(frm){
@ -439,7 +439,7 @@ function variant(frm){
service_kilometers: frm.doc.service_kilometers
},
callback: function (r) {
console.log(r.message)
// console.log(r.message)
frm.set_df_property('kilometers', 'options', r.message);
frm.refresh_field('kilometers')
}

19
smart_service/phase_2/doctype/qwik_service/qwik_service.json

@ -6,6 +6,8 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"section_break_lb75u",
"variant",
"kilometers",
"language",
@ -38,7 +40,6 @@
"fieldname": "kilometers",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Kilometers",
"reqd": 1
},
@ -60,8 +61,6 @@
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"read_only": 1,
"reqd": 1
@ -110,7 +109,7 @@
},
{
"fieldname": "service_time",
"fieldtype": "Data",
"fieldtype": "Int",
"label": "Service Time",
"reqd": 1
},
@ -129,11 +128,21 @@
"fieldname": "keywords",
"fieldtype": "Small Text",
"label": "Keywords"
},
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "section_break_lb75u",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-21 15:39:08.512304",
"modified": "2023-09-22 13:05:24.032814",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Qwik Service",

4
smart_service/phase_2/doctype/qwik_service/qwik_service.py

@ -24,6 +24,8 @@ class QwikService(Document):
self.my_id = count[0][0] + 1
else:
self.my_id = 1
if self.keywords:
self.keywords=self.keywords.strip()
except Exception as e:
raise e
@ -97,6 +99,6 @@ def delete_qwik_data(values):
frappe.log_error("delete_qwik_data", str(e))
@frappe.whitelist()
def get_kilometer(vehicle):
def get_kilometer(vehicle=None):
kilometer_list = frappe.db.sql("""select service_kilometers from `tabVehicle_SK` where parent='%s'; """%(vehicle),as_list=1)
return kilometer_list

29
smart_service/phase_2/doctype/qwik_service_publish_data/qwik_service_publish_data.json

@ -11,8 +11,8 @@
"language",
"vehicle",
"kilometers",
"display_order",
"parent1"
"parent1",
"active_status"
],
"fields": [
{
@ -24,12 +24,16 @@
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Variant",
"options": "Variant Mapping"
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Language",
"options": "Custom Languages"
},
@ -37,29 +41,38 @@
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Parent",
"options": "Qwik Service"
},
{
"fieldname": "kilometers",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Kilometers"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Active Status",
"options": "Active\nInactive"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-20 10:18:35.308857",
"modified": "2023-09-22 17:26:16.909061",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Qwik Service Publish Data",

0
smart_service/phase_2/doctype/qwik_service_publish_docs/__init__.py

77
smart_service/phase_2/doctype/qwik_service_publish_docs/qwik_service_publish_docs.json

@ -0,0 +1,77 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-09-22 11:42:59.443590",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"variant",
"language",
"vehicle",
"kilometers",
"parent1",
"active_status"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping"
},
{
"fieldname": "language",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Language",
"options": "Custom Languages"
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Vehicle"
},
{
"fieldname": "kilometers",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Kilometers"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent",
"options": "Qwik Service"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Active Status",
"options": "Active\nInactive"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-22 18:05:07.905032",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Qwik Service Publish Docs",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/qwik_service_publish_docs/qwik_service_publish_docs.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class QwikServicePublishDocs(Document):
pass

123
smart_service/phase_2/doctype/special_tool_information/special_tool_information.js

@ -6,16 +6,31 @@ var vehicle_count = 0;
frappe.ui.form.on('Special Tool Information', {
onload: function (frm) {
// Set Display Order
set_display_order(frm)
set_display_order(frm),
teb_validation(frm)
},
refresh: function (frm) {
// Set Display Order
set_display_order(frm)
set_display_order(frm),
teb_validation(frm)
},
validate:function(frm){
//for display_order
if (frm.doc.display_order == null || typeof (frm.doc.display_order) == String) {
frappe.validated = false;
frm.doc.display_order = original_display_order
cur_frm.refresh_fields("display_order")
frappe.throw(__("<b>Display Order:</b> Invalid Characters not permitted."));
}
// Check negative display order
if (frm.doc.display_order <= 0 && frm.doc.display_order != null && typeof (frm.doc.display_order) != String) {
frappe.validated = false;
frm.doc.display_order = original_display_order
cur_frm.refresh_fields("display_order")
frappe.throw(__("<b>Display Order:</b> Zero or Negative values not allowed."));
}
//For Display Order
cur_frm.refresh_fields("display_order")
if (frm.doc.display_order && frm.doc.name && !frm.is_new()) {
@ -26,7 +41,6 @@ frappe.ui.form.on('Special Tool Information', {
display_order: frm.doc.display_order,
name: ["!=", frm.doc.name],
vehicle: frm.doc.vehicle,
}
}).then(records => {
if (records.length) {
@ -50,10 +64,57 @@ frappe.ui.form.on('Special Tool Information', {
}
},
category: function (frm, cdt, cdn) {
teb_validation(frm)
},
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
if (!frm.is_new()){
teb_validation(frm)
}
},
});
function teb_validation(frm){
if(frm.doc.category == "TEB"){
//to set df property to child readonly based on main doc
cur_frm.refresh_fields("instructions");
var df = frappe.meta.get_docfield("Instructions", "content", cur_frm.doc.name);
df.read_only = 1;
var dm = frappe.meta.get_docfield("Instructions", "step_name", cur_frm.doc.name);
dm.read_only = 1;
cur_frm.refresh_fields("content")
cur_frm.refresh_field('instructions');
cur_frm.refresh_fields();
//to set the content_type value to pdf
var is_pdf =1
if(frm.doc.instructions && frm.doc.instructions.length>0){
frm.doc.instructions.map(v=>{
if(v.content_type=="PDF"){
is_pdf=0
}
})
}
if(is_pdf==1){
var childTable = cur_frm.add_child("instructions");
childTable.content_type="PDF"
var df = frappe.meta.get_docfield("Instructions", "content_type", cur_frm.doc.name);
df.read_only = 1;
cur_frm.refresh_fields("category");
cur_frm.refresh_fields("instructions");
}
//end
}
//to nullify the table
if (frm.doc.Instructions && frm.doc.Instructions.length > 0) {
cur_frm.clear_table("Instructions");
cur_frm.refresh_fields('instructions');
cur_frm.refresh_fields();
}
}
function set_display_order(frm){
if (frm.is_new()) {
@ -75,40 +136,24 @@ function set_display_order(frm){
}
});
}
frappe.ui.form.on('MST Information Assets',{
asset_type: function (frm, cdt, cdn) {
var select_value = locals[cdt][cdn]
var x = select_value.idx - 1;
let my_row = frm.fields_dict.tool_usage_content.grid.grid_rows[x];
let task_index = my_row.docfields.findIndex(x => x.fieldname === "content");
if (select_value.asset_type == 'Image' || select_value.asset_type == 'Video') {
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.image.df.read_only = 0;
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.read_only = 1;
cur_frm.refresh_fields("tool_usage_content")
}
else {
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.image.df.read_only = 1;
cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.read_only = 0;
cur_frm.refresh_fields("tool_usage_content")
}
cur_frm.refresh_field("tool_usage_content");
cur_frm.refresh_field();
},
validate:function(frm){
let task_index = row.docfields.findIndex(x => x.fieldname === "content");
if (row.doc.asset_type == 'Image' || row.doc.asset_type == 'Video') {
row.docfields[task_index].read_only = 0;
// cur_frm.get_field("tool_usage_content").grid.grid_rows[x].columns.content.df.set="";
} else {
row.docfields[task_index].read_only = 1;
frappe.ui.form.on('Instructions', {
instructions_add: function (frm, cdt, cdn) {
refresh_field("instructions")
var child = locals[cdt][cdn];
var x = child.idx - 1;
if(frm.doc.category == "TEB"){
child.content_type = "PDF"
cur_frm.get_field("instructions").grid.grid_rows[x].columns.content_type.df.read_only = 1;
cur_frm.refresh_field("content_type")
}
row.toggle_editable_row(true);
refresh_field("tool_usage_content");
cur_frm.refresh_field("image");
cur_frm.refresh_field("content");
refresh_field();
else{
cur_frm.get_field("instructions").grid.grid_rows[x].columns.content_type.df.read_only = 0;
cur_frm.get_field("instructions").grid.grid_rows[x].columns.step_name.df.read_only = 0;
cur_frm.get_field("instructions").grid.grid_rows[x].columns.content.df.read_only = 0;
cur_frm.refresh_field("content_type")
cur_frm.refresh_field("step_name")
cur_frm.refresh_field("content")
}
refresh_field("instructions");
},
})

37
smart_service/phase_2/doctype/special_tool_information/special_tool_information.json

@ -1,7 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{tools}-{category}",
"autoname": "format:{vehicle}-{tool_type}-{category}-{aggregate_name}",
"creation": "2023-08-04 13:09:53.363093",
"doctype": "DocType",
"editable_grid": 1,
@ -10,7 +10,6 @@
"published",
"column_break_cyo0a",
"vehicle",
"tools",
"column_break_nkf5o",
"active_status",
"display_order",
@ -22,8 +21,11 @@
"my_id",
"section_break_e91wx",
"instructions",
"teb_instructions",
"keywords",
"pdf"
"pdf",
"tool_name",
"tool_type"
],
"fields": [
{
@ -93,15 +95,6 @@
"fieldtype": "Data",
"label": "Aggregate Name"
},
{
"fieldname": "tools",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Tools",
"options": "New Tool\nCarry Over",
"set_only_once": 1
},
{
"fieldname": "category",
"fieldtype": "Select",
@ -131,11 +124,29 @@
"fieldtype": "Table",
"label": "Instructions",
"options": "Instructions"
},
{
"fieldname": "tool_name",
"fieldtype": "Data",
"label": "Tool Name"
},
{
"fieldname": "tool_type",
"fieldtype": "Select",
"label": "Tool Type",
"options": "New Tool\nCarry Over"
},
{
"fieldname": "teb_instructions",
"fieldtype": "Table",
"hidden": 1,
"label": "TEB Instructions",
"options": "TEB Instructions"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-21 18:26:21.849846",
"modified": "2023-09-25 15:25:48.461308",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Information",

6
smart_service/phase_2/doctype/special_tool_information/special_tool_information.py

@ -12,6 +12,12 @@ class SpecialToolInformation(Document):
self.my_id = count[0][0] + 1
else:
self.my_id = 1
if self.keywords:
self.keywords=self.keywords.strip()
if self.aggregate_name:
self.aggregate_name=self.aggregate_name.strip()
if self.tool_name:
self.tool_name=self.tool_name.strip()
if not self.is_new() and self.published == 1:
self.published = 0

0
smart_service/phase_2/doctype/special_tool_publish_data/__init__.py

74
smart_service/phase_2/doctype/special_tool_publish_data/special_tool_publish_data.json

@ -0,0 +1,74 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-09-26 12:11:39.191042",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"vehicle",
"tool_type",
"category",
"active_status",
"parent1",
"aggregate_name"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "vehicle",
"fieldtype": "Link",
"label": "Vehicle",
"options": "Vehicle"
},
{
"fieldname": "tool_type",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Tool Type"
},
{
"fieldname": "category",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Category"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent",
"options": "Special Tool Information"
},
{
"fieldname": "aggregate_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Aggregate Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-26 13:29:17.325550",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Publish Data",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/special_tool_publish_data/special_tool_publish_data.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class SpecialToolPublishData(Document):
pass

0
smart_service/phase_2/doctype/special_tool_publish_docs/__init__.py

74
smart_service/phase_2/doctype/special_tool_publish_docs/special_tool_publish_docs.json

@ -0,0 +1,74 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-09-26 12:10:57.200869",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"vehicle",
"tool_type",
"category",
"active_status",
"aggregate_name",
"parent1"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "vehicle",
"fieldtype": "Link",
"label": "Vehicle",
"options": "Vehicle"
},
{
"fieldname": "tool_type",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Tool Type"
},
{
"fieldname": "category",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Category"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent",
"options": "Special Tool Information"
},
{
"fieldname": "aggregate_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Aggregate Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-26 13:29:01.388047",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Special Tool Publish Docs",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/special_tool_publish_docs/special_tool_publish_docs.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class SpecialToolPublishDocs(Document):
pass

0
smart_service/phase_2/doctype/teb_instructions/__init__.py

30
smart_service/phase_2/doctype/teb_instructions/teb_instructions.json

@ -0,0 +1,30 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-09-25 15:00:01.484863",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"attach_file"
],
"fields": [
{
"fieldname": "attach_file",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Attach File"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-09-25 15:01:03.679402",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "TEB Instructions",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/teb_instructions/teb_instructions.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class TEBInstructions(Document):
pass

7
smart_service/public/js/common_fun.js

@ -34,6 +34,7 @@ function dragovertFunction(evt) {
})
//end
if (children.indexOf(e.target.parentNode) > children.indexOf(row)) {
console.log(e,"---e")
e.target.parentNode.after(row);
}
else {
@ -149,10 +150,10 @@ function dragovertFunctionQwik(evt) {
// $('.specification_bl').find('.spec_custom_save').css("display","inline-block")
})
//end
if (children.indexOf(e.target.parentNode) > children.indexOf(row)) {
e.target.parentNode.after(row);
if (children.indexOf(e.target.parentNode) > children.indexOf(row3)) {
e.target.parentNode.after(row3);
}
else {
e.target.parentNode.before(row);
e.target.parentNode.before(row3);
}
}

1
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js

@ -209,6 +209,7 @@ frappe.ui.form.on('Kilometer Mapping', {
sort_by_kilometer: function (frm) {
var idx = 1;
frm.doc.config_kilometer.sort(function (a, b) {
console.log(a.kilometer + 'Kilometer' + b.kilometer)
if (parseInt(a.kilometer) < parseInt(b.kilometer)) { return -1 }
else if (parseInt(a.kilometer) > parseInt(b.kilometer)) { return 1 }
return 1;

3
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json

@ -159,7 +159,6 @@
{
"fieldname": "temp_field",
"fieldtype": "Select",
"hidden": 1,
"label": "Temp Field",
"options": "\nSet\nNot Set"
},
@ -173,7 +172,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-05-14 12:06:07.658115",
"modified": "2023-09-26 17:48:09.485301",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Kilometer Mapping",

422
smart_service/transactions/doctype/publish/publish.js

@ -35,8 +35,24 @@ frappe.ui.form.on("Publish", {
cur_frm.set_df_property("feature_finder_publish_docs", "read_only", 1);
frm.refresh_field("feature_finder_publish_docs");
}
if (
frm.doc.hasOwnProperty("qwik_service_publish_docs") &&
frm.doc.qwik_service_publish_docs.length > 0
) {
frm.set_df_property("qwik_service_publish_docs", "hidden", 0);
cur_frm.set_df_property("qwik_service_publish_docs", "read_only", 1);
frm.refresh_field("qwik_service_publish_docs");
}
if (
frm.doc.hasOwnProperty("special_tool_publish_docs") &&
frm.doc.special_tool_publish_docs.length > 0
) {
frm.set_df_property("special_tool_publish_docs", "hidden", 0);
cur_frm.set_df_property("special_tool_publish_docs", "read_only", 1);
frm.refresh_field("special_tool_publish_docs");
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Feature Finder") {
cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.set_df_property("feature_finder_publish_docs", "read_only", 1);
cur_frm.refresh_field("feature_finder_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
@ -65,6 +81,35 @@ frappe.ui.form.on("Publish", {
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Qwik Service") {
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.set_df_property("qwik_service_publish_docs", "read_only", 1);
cur_frm.refresh_field("qwik_service_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.feature_finder_publish.length > 0) {
frm.set_df_property("qwik_service_publish", "hidden", 1);
frm.refresh_field("qwik_service_publish");
cur_frm.set_df_property("qwik_service_publish", "read_only", 1);
}
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Special Tool") {
cur_frm.set_df_property("special_tool_publish_docs", "read_only", 1);
// cur_frm.set_df_property("special_tool_publish_docs", "hidden", 1);
cur_frm.refresh_field("special_tool_publish_docs");
cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.special_tool_publish.length > 0) {
frm.set_df_property("special_tool_publish", "hidden", 0);
frm.refresh_field("special_tool_publish_docs");
cur_frm.set_df_property(
"special_tool_publish_docs",
"read_only",
1
);
}
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
if (
(frm.doc.docstatus != 1 &&
frm.doc.publish_module == "Feature Finder" &&
@ -72,7 +117,7 @@ frappe.ui.form.on("Publish", {
frm.doc.publish_type == "Internal") ||
frm.doc.publish_type == "Global"
) {
cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.refresh_field("feature_finder_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
@ -93,6 +138,33 @@ frappe.ui.form.on("Publish", {
cur_frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 0);
cur_frm.refresh_field("repiar_checksheet_publish_docs");
}
if (
(frm.doc.docstatus != 1 &&
frm.doc.publish_module == "Qwik Service" &&
frm.doc.qwik_service_publish_docs.length > 0 &&
frm.doc.publish_type == "Internal") ||
frm.doc.publish_type == "Global"
) {
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.refresh_field("qwik_service_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
cur_frm.remove_custom_button("Add To Publish");
cur_frm.set_df_property("qwik_service_publish_docs", "hidden", 0);
cur_frm.refresh_field("qwik_service_publish_docs");
}
if (
(frm.doc.docstatus != 1 && frm.doc.publish_module == "Special Tool") ||
frm.doc.publish_type == "Internal" ||
frm.doc.publish_type == "Global"
) {
cur_frm.refresh_field("special_tool_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
cur_frm.remove_custom_button("Add To Publish");
cur_frm.set_df_property("special_tool_publish_docs", "hidden", 1);
cur_frm.refresh_field("special_tool_publish_docs");
}
// $('[data-route="Form/Publish/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish")
if (
@ -180,7 +252,7 @@ frappe.ui.form.on("Publish", {
module_name: frm.doc.publish_module,
},
callback: function (r) {
debugger;
// debugger;
window.location.href =
r.message.url +
"/app/publish" +
@ -199,16 +271,17 @@ frappe.ui.form.on("Publish", {
}
if (frm.doc.publish_module == "Automotive System") {
cur_frm.set_df_property("system_mapping", "read_only", 1);
//Jeci comment
// cur_frm.set_df_property("system_mapping", "read_only", 1);
cur_frm.fields_dict["system_mapping"].grid.wrapper
.find(".grid-add-row")
.hide();
cur_frm.fields_dict["system_mapping"].grid.wrapper
.find(".grid-upload")
.hide();
cur_frm.fields_dict["system_mapping"].grid.wrapper
.find(".grid-remove-rows")
.hide();
// cur_frm.fields_dict["system_mapping"].grid.wrapper
// .find(".grid-remove-rows")
// .hide();
cur_frm.fields_dict["system_mapping"].grid.wrapper
.find(".grid-insert-row")
.hide();
@ -536,6 +609,7 @@ frappe.ui.form.on("Publish", {
doc: frm.doc.name,
},
callback: function (r) {
if (r.message) {
frm.set_value("version", r.message);
cur_frm.refresh_field("version");
@ -578,7 +652,9 @@ frappe.ui.form.on("Publish", {
if (
frm.doc.publish_module != "Automotive System" &&
!frm.doc.hasOwnProperty("repair_checksheet_publish") &&
!frm.doc.hasOwnProperty("feature_finder_publish")
!frm.doc.hasOwnProperty("feature_finder_publish") &&
!frm.doc.hasOwnProperty("qwik_service_publish") &&
!frm.doc.hasOwnProperty("special_tool_publish")
) {
frappe.throw("No Data Found To Publish");
}
@ -696,6 +772,9 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Feature Finder") {
add_feature_finder(frm);
}
if(frm.doc.publish_module == "Qwik Service"){
add_qwik_service(frm)
}
// if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Feature Finder') {
// frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
@ -990,6 +1069,9 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Repair service") {
add_to_publish(frm);
}
if (frm.doc.publish_module == "Special Tool") {
add_special_tool(frm);
}
if (
frm.doc.vehicle === undefined ||
(frm.doc.vehicle === null &&
@ -1012,14 +1094,37 @@ frappe.ui.form.on("Publish", {
cur_frm.refresh_fields("repair_checksheet_publish");
}
}
if (frm.doc.publish_module == "Qwik service") {
if (
frm.doc.repair_checksheet_publish &&
frm.doc.repair_checksheet_publish.length > 0
) {
content_flag = 1;
cur_frm.clear_table("qwik_service_publish");
cur_frm.refresh_fields("qwik_service_publish");
}
}
if (frm.doc.publish_module == "Special Tool") {
if (
frm.doc.special_tool_publish &&
frm.doc.special_tool_publish.length > 0
) {
content_flag = 1;
cur_frm.clear_table("special_tool_publish");
cur_frm.refresh_fields("special_tool_publish");
}
}
},
language: function (frm) {
frm.doc.vehicle = "";
frm.refresh_field("vehicle");
frm.set_value("repair_checksheet_publish", "");
frm.set_value("feature_finder_publish", "");
frm.set_value("qwik_service_publish","");
frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("feature_finder_publish_docs", "");
frm.set_value("qwik_service_publish_docs", "");
if (frm.doc.publish_module == "Repair service" && frm.doc.vehicle) {
add_to_publish(frm);
@ -1046,6 +1151,20 @@ frappe.ui.form.on("Publish", {
}
}
if (
frm.doc.publish_module == "Qwik Service" &&
frm.doc.vehicle &&
frm.doc.variant_mapping
) {
if (
frm.doc.qwik_service_publish &&
frm.doc.qwik_service_publish.length > 0
) {
cur_frm.clear_table("qwik_service_publish");
cur_frm.refresh_fields("qwik_service_publish");
}
}
if (!lang_set_first_time && frm.doc.publish_module == "Automotive System") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
@ -1089,7 +1208,24 @@ frappe.ui.form.on("Publish", {
// action to perform if No is selected
}
);
} else {
}
if (!lang_set_first_time && frm.doc.publish_module == "Qwik Service") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
frm.set_value("qwik_service_publish", null);
frm.set_value("variant_mapping", "");
lang_set_first_time = false;
},
() => {
// action to perform if No is selected
}
);
}
else {
lang_set_first_time = false;
}
},
@ -1124,8 +1260,12 @@ frappe.ui.form.on("Publish", {
frm.doc.variant_mapping = "";
frm.doc.repair_checksheet_publish = "";
frm.doc.feature_finder_publish = "";
frm.doc.qwik_service_publish="";
frm.doc.special_tool_publish="";
frm.set_value("feature_finder_publish_docs", "");
frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("qwik_service_publish_docs", "");
frm.set_value("special_tool_publish_docs","");
frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1);
frm.refresh_fields();
if (frm.doc.publish_module == "Repair service") {
@ -1137,12 +1277,18 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Feature Finder") {
add_feature_finder(frm);
}
if(frm.doc.publish_module == "Qwik Service"){
add_qwik_service(frm)
}
if (frm.doc.publish_module == "special Tool") {
add_special_tool(frm);
}
},
});
frappe.ui.form.on("Publish_Temp Doc", {
form_render(frm, cdt, cdn) {
frm.fields_dict.system_mapping.grid.wrapper.find(".grid-delete-row").hide();
// frm.fields_dict.system_mapping.grid.wrapper.find(".grid-delete-row").hide();
frm.fields_dict.system_mapping.grid.wrapper
.find(".grid-duplicate-row")
.hide();
@ -1418,3 +1564,259 @@ function add_feature_finder(frm) {
},
});
}
function add_qwik_service(frm){
cur_frm.clear_table("Qwik_service_publish");
cur_frm.refresh_fields();
frappe.call({
method:"smart_service.transactions.doctype.publish.publish.get_qwik_service",
args:{
variant: frm.doc.variant_mapping,
language_label: frm.doc.language,
publish_type: frm.doc.publish_type
},
callback:function(r){
if (r.message.length > 0){
cur_frm.set_df_property("qwik_service_publish", "hidden", 0);
var records = r.message;
records.map((v) => {
var childTable = cur_frm.add_child("qwik_service_publish");
childTable.parent1 = v["name"];
childTable.language = v["language"];
childTable.variant = v["variant"];
childTable.active_status = v["active_status"];
childTable.kilometers = v["kilometers"]
});
//add to repair service published doc table
if (
frm.doc.docstatus === 0 &&
frm.doc.publish_status == "To Publish" &&
frm.doc.publish_module == "Qwik Service"
){
frm
.get_field("qwik_service_publish")
.grid.add_custom_button(__("Add to Publish"), function () {
let added = 0;
frm.doc.qwik_service_publish.forEach((row) => {
if (
row.active_status == "Active" ||
row.active_status == "Inactive"
) {
let dulicate = false;
if (frm.doc.qwik_service_publish_docs) {
frm.doc.qwik_service_publish_docs.forEach(
(publishrow) => {
if (row.parent1 == publishrow.parent1) {
dulicate = true;
}
}
);
}
if (dulicate === false) {
let child = cur_frm.add_child(
"qwik_service_publish_docs"
);
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
child.kilometers = row.kilometers;
child.active_status = row.active_status;
added += 1;
frm.set_df_property(
"qwik_service_publish_docs",
"hidden",
0
);
cur_frm.refresh_field(
"qwik_service_publish",
"read_only",
1
);
refresh_field("qwik_service_publish_docs");
cur_frm.set_df_property(
"qwik_service_publish",
"read_only",
1
);
document
.getElementsByClassName(
"btn btn-xs btn-secondary grid-add-row"
)[4]
.setAttribute("style", "display:none;");
document
.getElementsByClassName(
"btn btn-xs btn-secondary grid-add-row"
)[5]
.setAttribute("style", "display:none;");
frm.fields_dict.qwik_service_publish.grid.grid_buttons
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
}else {
frappe.msgprint(__(row.parent1 + "Alraeady Added"));
}
cur_frm.refresh_field(
"qwik_service_publish_docs",
"read_only",
1
);
}
});
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property(
"qwik_service_publish",
"read_only",
1
);
cur_frm.set_df_property(
"qwik_service_publish_docs",
"read_only",
1
);
cur_frm.refresh_field("qwik_service_publish");
}else if (added == 0) {
frappe.msgprint(__("No Doc Added"));
}
});
frm.fields_dict.qwik_service_publish.grid.grid_buttons
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
}
cur_frm.set_df_property("qwik_service_publish", "hidden", 0);
cur_frm.refresh_field("qwik_service_publish");
let find_add_btn = document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[3]
.setAttribute("style", "display:none;");
}
}
})
}
function add_special_tool(frm) {
cur_frm.clear_table("special_tool_publish");
cur_frm.refresh_fields();
document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[4]
.setAttribute("style", "display:none;");
if (frm.doc.vehicle) {
frappe.call({
method:
"smart_service.transactions.doctype.publish.publish.get_special_tool",
args: {
vehicle: frm.doc.vehicle,
publish_type: frm.doc.publish_type,
},
callback: function (r) {
if (r.message.length > 0) {
var records = r.message;
records.map((v) => {
var childTable = cur_frm.add_child("special_tool_publish");
childTable.parent1 = v["name"];
childTable.vehicle = v["vehicle"];
childTable.aggregate_name = v["aggregate_name"];
childTable.tool_type = v["tool_type"];
childTable.active_status = v["active_status"];
childTable.category = v["category"];
});
//add to repair service published doc table
if (
frm.doc.docstatus === 0 &&
frm.doc.publish_status == "To Publish" &&
frm.doc.publish_module == "Special Tool"
) {
frm
.get_field("special_tool_publish")
.grid.add_custom_button(__("Add to Publish"), function () {
let added = 0;
frm.doc.special_tool_publish.forEach((row) => {
if (
row.active_status == "Active" ||
row.active_status == "Inactive"
) {
let dulicate = false;
if (frm.doc.special_tool_publish_docs) {
frm.doc.special_tool_publish_docs.forEach(
(publishrow) => {
if (row.parent_name == publishrow.parent_name) {
dulicate = true;
}
}
);
}
if (dulicate === false) {
let child = cur_frm.add_child(
"special_tool_publish_docs"
);
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.category = row.category;
child.aggregate_name = row.aggregate_name;
child.tool_type = row.tool_type;
child.active_status = row.active_status;
// refresh_field("repiar_checksheet_publish_docs");
added += 1;
frm.set_df_property(
"special_tool_publish_docs",
"hidden",
0
);
refresh_field("special_tool_publish_docs");
document
.getElementsByClassName(
"btn btn-xs btn-secondary grid-add-row"
)[4]
.setAttribute("style", "display:none;");
document
.getElementsByClassName(
"btn btn-xs btn-secondary grid-add-row"
)[5]
.setAttribute("style", "display:none;");
} else {
frappe.msgprint(__(row.parent_name + "Alraeady Added"));
}
}
});
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property(
"special_tool_publish",
"read_only",
1
);
cur_frm.refresh_field("special_tool_publish");
} else if (added == 0) {
frappe.msgprint(__("No Doc Added"));
}
});
frm.fields_dict.special_tool_publish.grid.grid_buttons
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
}
cur_frm.set_df_property("special_tool_publish", "hidden", 0);
cur_frm.refresh_field("special_tool_publish");
cur_frm.set_df_property(
"special_tool_publish_docs",
"read_only",
1
);
cur_frm.refresh_field(
"special_tool_publish_docs",
"read_only",
1
);
document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[4]
.setAttribute("style", "display:none;");
document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[5]
.setAttribute("style", "display:none;");
}
},
});
}
}

52
smart_service/transactions/doctype/publish/publish.json

@ -47,7 +47,11 @@
"feature_finder_publish",
"feature_finder_publish_docs",
"repair_checksheet_publish",
"repiar_checksheet_publish_docs"
"repiar_checksheet_publish_docs",
"qwik_service_publish",
"qwik_service_publish_docs",
"special_tool_publish",
"special_tool_publish_docs"
],
"fields": [
{
@ -102,7 +106,7 @@
"set_only_once": 1
},
{
"depends_on": "eval:doc.vehicle && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Feature Finder'",
"depends_on": "eval:doc.vehicle && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Feature Finder' || doc.publish_module=='Qwik Service' ",
"fieldname": "variant_mapping",
"fieldtype": "Link",
"label": "Variant Mapping",
@ -113,15 +117,13 @@
"depends_on": "eval:doc.docstatus == 0",
"fieldname": "system_n_sub_systems",
"fieldtype": "Section Break",
"label": "System & Sub Systems",
"read_only": 1
"label": "System & Sub Systems"
},
{
"fieldname": "system_mapping",
"fieldtype": "Table",
"label": "System Mapping",
"options": "Publish_Temp Doc",
"read_only": 1
"options": "Publish_Temp Doc"
},
{
"allow_bulk_edit": 1,
@ -319,7 +321,7 @@
"fieldname": "publish_module",
"fieldtype": "Select",
"label": "Module",
"options": "Automotive System\nFeature Finder\nRepair service",
"options": "Automotive System\nFeature Finder\nRepair service\nQwik Service\nSpecial Tool",
"reqd": 1
},
{
@ -331,7 +333,7 @@
"options": "Feature Finder Publish Data"
},
{
"depends_on": "eval:doc.publish_module=='Repair service';",
"depends_on": "eval:doc.publish_module =='Repair service';",
"fieldname": "repair_checksheet_publish",
"fieldtype": "Table",
"hidden": 1,
@ -352,12 +354,44 @@
"hidden": 1,
"label": "Feature Finder Publish Docs",
"options": "Feature Finder Publish Docs"
},
{
"depends_on": "eval:doc.publish_module =='Qwik Service';",
"fieldname": "qwik_service_publish",
"fieldtype": "Table",
"hidden": 1,
"label": "Qwik Service Publish",
"options": "Qwik Service Publish Data"
},
{
"depends_on": "eval:doc.publish_module=='Qwik Service';",
"fieldname": "qwik_service_publish_docs",
"fieldtype": "Table",
"hidden": 1,
"label": "Qwik Service Publish Docs",
"options": "Qwik Service Publish Docs"
},
{
"depends_on": "eval:doc.publish_module =='Special Tool';",
"fieldname": "special_tool_publish",
"fieldtype": "Table",
"hidden": 1,
"label": "Special Tool Publish",
"options": "Special Tool Publish Data"
},
{
"depends_on": "eval:doc.publish_module =='Special Tool';",
"fieldname": "special_tool_publish_docs",
"fieldtype": "Table",
"hidden": 1,
"label": "Special Tool Publish Docs",
"options": "Special Tool Publish Docs"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-09-04 12:02:32.394888",
"modified": "2023-09-26 17:30:50.606211",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

376
smart_service/transactions/doctype/publish/publish.py

@ -65,7 +65,23 @@ class Publish(Document):
self.repiar_checksheet_publish_docs)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Internal':
qwik_service_publish(self.vehicle, self.vehicle_id,self.variant,
self.language,self.publish_type,
self.release_description,self.qwik_service_publish_docs)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Global' and self.qwik_service_publish_docs:
qwik_service_publish(self.vehicle, self.vehicle_id,self.variant,
self.language,self.publish_type,
self.release_description,self.qwik_service_publish_docs)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
update_qwik_published_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.publish_type == 'Internal' and self.feature_finder_publish_docs:
feature_finder_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
@ -90,8 +106,24 @@ class Publish(Document):
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Internal':
special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type,
self.release_description,
self.special_tool_publish_docs)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Global' and self.special_tool_publish_docs:
special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type,
self.release_description,
self.special_tool_publish_docs)
update_special_tool_publish_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
variant = self.variant_mapping_details.split('/n')
frappe.log_error('variant', str(variant))
# for v in variant:
# frappe.log_error('v', str(v))
@ -156,7 +188,15 @@ def update_procedure(vehicle, lang, publish_type, doc):
frappe.throw("There is no item for global publish")
# Generate Publish versions
def update_qwik_published_docs(self):
try:
for d in self.qwik_service_publish_docs:
frappe.db.sql(
"""UPDATE `tabQwik Service` set is_published=1 where name='{0}'""".format(d.parent1))
frappe.db.commit()
except Exception as ex:
return str(ex)
def update_publish_mapping(vehicle, variant, language, module, publish_type):
frappe.set_user('Administrator')
@ -322,7 +362,29 @@ def generate_global_publish(name, module_name):
"publish_module": res.publish_module,
"repiar_checksheet_publish_docs": res.repiar_checksheet_publish_docs
})
elif module_name == 'Qwik Service':
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
"qwik_service_publish_docs": res.qwik_service_publish_docs,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module
})
elif module_name == 'Special Tool':
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"special_tool_publish_docs": res.special_tool_publish_docs,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module
})
ret.save()
return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()}
except Exception as e:
@ -518,6 +580,17 @@ def update_repair_published_docs(self):
except Exception as e:
frappe.throw(str(e))
def update_special_tool_publish_docs(self):
try:
for d in self.special_tool_publish_docs:
frappe.db.sql(
"""UPDATE `tabSpecial Tool Information` set published=1 where name='{0}'""".format(d.parent1))
frappe.db.commit()
except Exception as e:
frappe.throw(str(e))
def create_publish_folders(folder_url):
try:
@ -533,7 +606,6 @@ def create_publish_folders(folder_url):
frappe.throw(str(e))
return False
'''New Module Publish Section'''
@ -647,6 +719,8 @@ def repair_checksheet_publish(vehicle, vehicle_id,
frappe.throw('Failed To Publish')
def feature_finder_publish(vehicle=None, vehicle_id=None,
language=None, publish_type=None,
release_description=None, parent=None,
@ -759,6 +833,210 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
f'{vehicle} - {language} - {publish_type} - {module_name} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def qwik_service_publish(vehicle = None , vehicle_id = None,variant = None,
language = None,publish_type = None,
release_description=None,parent = None):
try:
logger_file = f'{variant} - {language} - {publish_type} - Qwik_service'
logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(
f'Qwik_service-{variant}-{language}-{publish_type}-{parent}')
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Publish Ready Flags'''
publish_qwik_service = 0
qwik_service_tmp = []
qwik_service=''
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-qwik_service' + '.json'
global_file_path = folder_url + "/" + "Global" + "/" + \
vehicle.replace(' ', '-') + '-qwik_service' + '.json'
exising_internal_path = folder_url + "/" + "Internal" + "/" + \
vehicle.replace(' ', '-') + '-qwik_service' + '.json'
'''Append Published Data to Json'''
logger.info(
f'Qwik_service Data Append Start::{vehicle}-{language}-{publish_type}')
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'variant':variant,
'publish_type': publish_type,
'publish_description': release_description,
'publish_language': language,
'data': ''
}
if os.path.isfile(global_file_path) and publish_type == 'Internal':
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
qwik_service = qwik_service_data(
language,publish_type,i.variant,i.parent1,vehicle)
if qwik_service['status'] == 1 and len(qwik_service['data'])>0:
publish_qwik_service = 1
qwik_service_tmp.append(
qwik_service['data'][0])
qwik_service_tmp = create_df(qwik_service_tmp)
vehi_data = compare_get_data({'data': published_data['data']}, {
'data': qwik_service_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
x for x in new_variant if x not in find_distinct]
vehi_data = add_new_val(
vehi_data, new_variant_name, qwik_service_tmp)
elif os.path.isfile(global_file_path) and publish_type == 'Global':
frappe.msgprint(str('compare_internal'))
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
qwik_service = qwik_service_data(
language,publish_type,i.variant,i.parent1,vehicle)
if qwik_service['status'] == 1 and len(qwik_service['data'])>0:
publish_qwik_service = 1
qwik_service_tmp.append(
qwik_service['data'][0])
frappe.log_error(str(qwik_service_tmp))
qwik_service_tmp = create_df(qwik_service_tmp)
vehi_data = compare_get_data({'data': published_data['data']}, {
'data': qwik_service_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
x for x in new_variant if x not in find_distinct]
vehi_data = add_new_val(
vehi_data, new_variant_name, qwik_service_tmp)
else:
for i in parent:
qwik_service = qwik_service_data(
language,publish_type,i.variant,i.parent1,vehicle)
if qwik_service['status'] == 1 and len(qwik_service['data'])>0:
publish_qwik_service = 1
qwik_service_tmp.append(
qwik_service['data'][0])
else:
frappe.throw('failed to publish')
qwik_service_tmp = get_latest_data(
{'data': qwik_service_tmp}, {'data': []})
vehi_data = create_df(qwik_service_tmp)
""" Save publish file """
vehicle_data['data'] = vehi_data
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
except Exception as e:
logger.error(f'{variant} - {language} - {publish_type} - Qwik_service'+str(e))
def special_tool_publish(vehicle, vehicle_id,
publish_type, release_description,
parent=None):
# special_tool_publish(self.vehicle, self.vehicle_id,
# self.publish_type,
# self.release_description,
# self.special_tool_publish_docs)
try:
frappe.log_error(str(parent))
logger_file = f'{vehicle} - {publish_type} - special tool'
logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(
f'Special Tool Started-{vehicle}-{publish_type}-{parent}')
folder_url = base_url+"/"+vehicle.replace(' ', '-')
logger.info(f'Created Folder-{vehicle}-{publish_type}')
'''Publish Ready Flags'''
publish_special_tool = 0
special_tool_tmp = []
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-special_tool' + '.json'
existing_global= folder_url + "/" + "Global" + "/" + \
vehicle.replace(' ', '-') + '-special_tool' + '.json'
# frappe.msgprint(str(existing_global))
'''Append Published Data to Json'''
logger.info(
f'Special tool Data Append Start::{vehicle}-{publish_type}')
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'publish_type': publish_type,
'publish_description': release_description,
'data': ''
}
'''update existing global json file'''
if os.path.isfile(existing_global) and publish_type=='Internal':
# frappe.msgprint(str('exiting'))
with open(existing_global) as f:
published_data = json.load(f)
for i in parent:
special_tool = special_tool_data(vehicle,publish_type, i.parent1)
if special_tool['status'] == 1 and len(special_tool['data'])>0:
publish_special_tool = 1
special_tool_tmp.append(
special_tool['data'][0])
frappe.log_error(str(special_tool_tmp))
special_tool_tmp = get_latest_data({'data': published_data['data']}, {
'data': special_tool_tmp})
elif os.path.isfile(file_path) and publish_type=='Global':
# frappe.msgprint(str('exiting Global'))
with open(existing_global) as f:
published_data = json.load(f)
for i in parent:
special_tool = special_tool_data(vehicle,publish_type, i.parent1)
if special_tool['status'] == 1 and len(special_tool['data'])>0:
publish_special_tool = 1
special_tool_tmp.append(
special_tool['data'][0])
frappe.log_error(str(special_tool_tmp))
special_tool_tmp = get_latest_data({'data': published_data['data']}, {
'data': special_tool_tmp})
else:
for i in parent:
special_tool = special_tool_data(
vehicle, publish_type, i.parent1)
frappe.log_error(str(special_tool))
if special_tool['status'] == 1:
publish_special_tool = 1
if len(special_tool['data'])>0:
special_tool_tmp.append(
special_tool['data'][0])
# frappe.msgprint(str(special_tool['data'][0]))
special_tool_tmp = get_latest_data(
{'data': special_tool_tmp}, {'data': []})
if publish_special_tool== 1:
""" Save publish file """
vehicle_data['data'] = special_tool_tmp
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
return 1, file_path
except Exception as e:
logger.info(
f'{vehicle} - {publish_type} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def get_key_value_data(data):
module_dic = {}
@ -769,6 +1047,8 @@ def get_key_value_data(data):
def get_latest_data(prev_data, latest_data):
try:
logger_file = "remove inactive start"
logger = frappe.logger(logger_file, allow_site=True, file_count=100)
data_dic1 = get_key_value_data(prev_data)
data_dic2 = get_key_value_data(latest_data)
@ -784,9 +1064,10 @@ def get_latest_data(prev_data, latest_data):
final_dic.update({d2: data_dic2[d2]})
final_list = list(final_dic.values())
logger.info("remove inactive end")
return final_list
except Exception as e:
logger.error("remove inactive error"+str(e))
frappe.throw(str(e))
@ -994,13 +1275,86 @@ def feature_finder_data(vehicle=None, language=None,
e)
logger.error('error in repair checksheet' + str(e))
return failure_reponse
def qwik_service_data(language,publish_type,variant,parent,vehicle):
try:
logger_file = f'fetch qwik data {variant} - {language}'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of qwik service data {variant} - {language}")
qwik_service_details = frappe.db.sql('''select name,variant,vehicle,kilometers,language,service_time,active_status,
pdf,display_order,keywords,my_id from `tabQwik Service` where name='%s';''' %
(parent), as_dict=1)
for q in qwik_service_details:
q['pre_work'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where parent='%s'
&& content_type = 'Pre-work' order by display_order;''' % (q['name']), as_dict=1)
q['consumables'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Consumables' order by display_order;''' % (q['name']), as_dict=1)
q['tools'] = frappe.db.sql('''select idx as 'display_order', content from `tabQwik Service Content` where
parent='%s' && content_type = 'Tools' order by display_order;''' % (q['name']), as_dict=1)
for p in qwik_service_details:
# p['qwik_procedure'] = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
# where parent ='%s';''' % (p['name']), as_dict=1)
LHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'LHS';''' % (p['name']), as_dict=1)
RHS = frappe.db.sql('''select idx as 'display_order',side,level,content from `tabQwik Procedure`
where parent ='%s' and side = 'RHS';''' % (p['name']), as_dict=1)
p['qwik_procedure'] = {'LHS': LHS, 'RHS': RHS}
logger.info(
f"end of qwik service data {variant} - {language}")
success_reponse['data'] = qwik_service_details
success_reponse[
'message'] = f'Qwik Service Fecthed Succesfully for {vehicle} - {language}'
return success_reponse
except Exception as e:
logger.error('error in qwik service data' + str(e))
def special_tool_data(vehicle=None,
publish_type=None, parent=None):
try:
logger_file = f'special_tool_data start'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching special tool data - {parent}")
special_tool_information = frappe.db.sql(''' select name,vehicle,tool_type,
category,tool_name,aggregate_name,aggregate_image,
pdf,keywords,display_order,my_id,active_status from
`tabSpecial Tool Information`
where name= '%s' ;''' % (parent), as_dict=1)
for s in special_tool_information:
s['instructions'] = frappe.db.sql('''select idx as 'display_order',step_name,
content_type,content,attach_file
from `tabInstructions` where parent = '%s'
order by display_order;''' % (s['name']), as_dict=1)
logger.info(
f"end of fetching special tool data {vehicle}")
success_reponse['data'] = special_tool_information
success_reponse[
'message'] = f'Special Tool Fecthed Succesfully for {vehicle} - special_tool_data '
return success_reponse
except Exception as e:
failure_reponse['error'] = f"{vehicle} has following error - " + str(
e)
logger.error('error in special tool' + str(e))
return failure_reponse
@frappe.whitelist()
def max_publish_new_module(doc):
doc = frappe.get_doc("Publish", doc)
ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}" and publish_module!="Automotive System";""".format(
current_db_name, doc.vehicle, doc.language))
if ver:
return ver
@ -1030,3 +1384,19 @@ def cal_ver_new_module(vehicle, lang, publish_type, doc):
current_db_name, v, doc.name))
frappe.db.commit()
return v
@frappe.whitelist()
def get_qwik_service(variant=None,language_label=None,kilometers=None):
try:
data = frappe.db.sql("""select * from `tabQwik Service` where variant='%s'
and language = '%s' and is_published = '%s';"""%(variant,language_label,0),as_dict=1)
return data
except Exception as e:
return e
@frappe.whitelist()
def get_special_tool(vehicle=None, publish_type=None):
data = frappe.db.sql('''
select * from `tabSpecial Tool Information` where vehicle ='%s' and published = '%s';'''%(vehicle,0), as_dict=1)
return data
Loading…
Cancel
Save