Browse Source

Feature finder, publish update

version2
venkataakhil 1 year ago
parent
commit
95192293d8
  1. 15
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  2. 5
      smart_service/phase_2/doctype/feature_finder/feature_finder.json
  3. 11
      smart_service/phase_2/doctype/publish_test/publish_test.js
  4. 4
      smart_service/phase_2/doctype/publish_test/publish_test.json
  5. 72
      smart_service/phase_2/doctype/publish_test/publish_test.py

15
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -7,31 +7,22 @@ var filter_value = 0
frappe.ui.form.on('Feature Finder', {
refresh: function (frm) {
// filter_value = "SOP"
// set_default_tab(frm,filter_value)
if (!frm.doc.feature_finder_images){
console.log("calling 1")
$(cur_frm.fields_dict.image_html.wrapper).empty();
}
if (!frm.is_new()) {
custom_tab_html(frm)
}
set_display_order(frm)
show_images(frm)
},
onload: function (frm) {
// filter_value = "SOP"
// set_default_tab(frm,filter_value)
if (!frm.doc.feature_finder_images){
console.log("calling 1")
$(cur_frm.fields_dict.image_html.wrapper).empty();
}
if (!frm.is_new()) {
custom_tab_html(frm)
}
set_display_order(frm)
show_images(frm)
@ -57,7 +48,7 @@ frappe.ui.form.on('Feature Finder', {
features_names: function (frm) {
frappe.db.get_list('Feature Finder Master', {
fields: ['name'],
fields: ['name','feature_category'],
filters: {
feature_name: frm.doc.features_names,
vehicle: frm.doc.vehicle
@ -66,10 +57,14 @@ frappe.ui.form.on('Feature Finder', {
console.log(records)
if(records.length>0){
frm.doc.feature_name = records[0].name
frm.doc.feature_category = records[0].feature_category
cur_frm.refresh_fields("feature_name")
cur_frm.refresh_fields("feature_category")
}else{
frm.doc.feature_name = ""
frm.doc.feature_category =""
cur_frm.refresh_fields("feature_name")
cur_frm.refresh_fields("feature_category")
}
})

5
smart_service/phase_2/doctype/feature_finder/feature_finder.json

@ -125,13 +125,14 @@
"options": "Feature Finder Specification"
},
{
"depends_on": "eval:doc.feature_name",
"fetch_from": "feature_name.feature_category",
"fieldname": "feature_category",
"fieldtype": "Data",
"label": "Feature Category"
},
{
"depends_on": "eval:doc.variant!=\"\"",
"depends_on": "eval:doc.variant",
"fieldname": "features_names",
"fieldtype": "Select",
"label": "Feature Name",
@ -173,7 +174,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-09 12:50:40.680301",
"modified": "2023-08-10 10:50:41.774687",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Feature Finder",

11
smart_service/phase_2/doctype/publish_test/publish_test.js

@ -334,10 +334,8 @@ frappe.ui.form.on('Publish Test', {
name: frm.doc.name
},
callback: function (r) {
debugger
if (r.message.status == "success") {
frm.set_df_property('repair_checksheet_publish','hidden',0)
frm.refresh_field('repair_checksheet_publish')
window.location.href = r.message.url + "/app/publish-test" + "/" + r.message.message
}
}
@ -413,8 +411,6 @@ frappe.ui.form.on('Publish Test', {
}
//check for atleast one data to publish
if(frm.doc.publish_module=='Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')){
debugger
frappe.throw('No Data Found To Publish')
@ -569,6 +565,11 @@ frappe.ui.form.on('Publish Test', {
km_report: function (frm, cdt, cdn) {
frappe.set_route("query-report", 'Kilometer Mapping', { 'kilometer_mapping': frm.doc.kilometer_mapping });
},
after_save:function(frm){
frm.set_df_property('repair_checksheet_publish','hidden',0)
frm.refresh_field('repair_checksheet_publish')
},
vehicle: function (frm) {
frappe.call({

4
smart_service/phase_2/doctype/publish_test/publish_test.json

@ -175,7 +175,7 @@
"fieldtype": "Column Break"
},
{
"depends_on": "eval:doc.vehicle && doc.docstatus == 0",
"depends_on": "eval:doc.vehicle && doc.docstatus == 0 && doc.publish_module=='Automotive'",
"fieldname": "variant_mapping",
"fieldtype": "Link",
"label": "Variant Mapping",
@ -327,7 +327,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-08-08 10:29:25.863957",
"modified": "2023-08-10 11:22:21.366394",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Publish Test",

72
smart_service/phase_2/doctype/publish_test/publish_test.py

@ -18,10 +18,9 @@ base_url = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"+"/json_files"+"/Other_Module"
frappe.utils.logger.set_log_level("DEBUG")
success_reponse={"status":1,"data":"","message":""}
failure_reponse={"status":0,"data":"","error":""}
class PublishTest(Document):
def validate(self):
self.published_date = str(date.today())
@ -48,9 +47,6 @@ class PublishTest(Document):
str(km_mapping.name) + '\n'
def on_submit(self):
if self.docstatus==1 and self.publish_status == 'To Publish' and self.publish_module=='Others' and self.publish_type=='Internal':
# for i in self.repair_checksheet_publish:
repair_checksheet_publish(self.vehicle,self.vehicle_id,self.language,self.publish_type,self.release_description,self.variant,self.repair_checksheet_publish)
update_publish_status=frappe.db.sql("""update `tabPublish Test` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus==1 and self.publish_module=='Others' and self.publish_type=='Global':
@ -425,7 +421,7 @@ def update_procedure_value(name, file_path):
frappe.db.commit()
@ frappe.whitelist()
@frappe.whitelist()
def get_service_repair(vehicle, language_label, publish_type):
data = frappe.db.sql(f'''
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0;
@ -448,43 +444,43 @@ def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_d
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + vehicle.replace(' ',
'-') +'.json'
try:
'''Append Published Data to Json'''
logger.info(f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'publish_type': publish_type,
'publish_description': release_description,
'publish_language': language,
'data':''
}
repair_checksheet_tmp=[]
for i in parent:
frappe.msgprint(str(i.parent_name))
repair_checksheet=repair_checksheet_data(vehicle,language,publish_type,i.parent_name)
frappe.msgprint(str(repair_checksheet))
if repair_checksheet['status']==1:
publish_repair_checksheet=1
'-')+'-repair_check_sheet' +'.json'
# try:
'''Append Published Data to Json'''
logger.info(f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'publish_type': publish_type,
'publish_description': release_description,
'publish_language': language,
'data':''
}
repair_checksheet_tmp=[]
for i in parent:
repair_checksheet=repair_checksheet_data(vehicle,language,publish_type,i.parent_name)
if repair_checksheet['status']==1:
publish_repair_checksheet=1
if len(repair_checksheet['data']):
repair_checksheet_tmp.append(repair_checksheet['data'][0])
if publish_repair_checksheet==1:
""" Save publish file """
vehicle_data['data']={'repair_checksheet':repair_checksheet_tmp}
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data,indent=4,default=str))
else:
logger.error(f'{vehicle}-{language}-{publish_type} error in json creation')
if publish_repair_checksheet==1:
""" Save publish file """
vehicle_data['data']={'repair_checksheet':repair_checksheet_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}-{language}-{publish_type} error in json creation'+str(e))
return e
# except Exception as e:
# logger.info(f'{vehicle}-{language}-{publish_type} error in json creation'+str(e))
# frappe.throw('Failed To Publish')
# return e
except Exception as e:
return e
frappe.throw('Failed To Publish')
def update_published_docs(self):
try:
if self.repair_checksheet_publish:
@ -492,7 +488,7 @@ def update_published_docs(self):
for d in self.repair_checksheet_publish:
frappe.db.sql(
"""UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(i.parent_name))
"""UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(d.parent_name))
frappe.db.commit()
except Exception as e:
frappe.throw(str(e))
@ -521,7 +517,7 @@ def repair_checksheet_data(vehicle=None,language=None,publish_type=None,parent=N
logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(f"start of fetching repair checksheet data-{vehicle}-{language}")
repair_service_details = frappe.db.sql(f""" select vehicle,vehicle_id,name,language,check_list_name,active_status,display_order,my_id from
`tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}' and active_status='Active' and name='{parent}'""", as_dict=1)
`tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}' and name='{parent}'""", as_dict=1)
for d in repair_service_details:
d['complaint'] = frappe.db.sql(f""" select complaint,remedial_action_ok,remedial_action_not_ok,idx as display_order,active_status from `tabRepair Service Child`
where parent = '{d['name']}' order by display_order ;""", as_dict=1)

Loading…
Cancel
Save