Browse Source

feature finder fix

version2
venkataakhil 1 year ago
parent
commit
35c8357070
  1. 79
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  2. 33
      smart_service/phase_2/doctype/publish_test/publish_test.py

79
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -9,36 +9,31 @@ frappe.ui.form.on('Feature Finder', {
refresh: function (frm) { refresh: function (frm) {
// filter_value = "SOP" // filter_value = "SOP"
// set_default_tab(frm,filter_value) // set_default_tab(frm,filter_value)
setTimeout(function mysam(){ if (!frm.doc.feature_finder_images){
if (!frm.doc.feature_finder_images){ console.log("calling 1")
console.log("calling 1") $(cur_frm.fields_dict.image_html.wrapper).empty();
$(cur_frm.fields_dict.image_html.wrapper).empty(); }
} if (!frm.is_new()) {
if (!frm.is_new()) { custom_tab_html(frm)
custom_tab_html(frm) }
}
},2000)
set_display_order(frm) set_display_order(frm)
// show_images(frm) show_images(frm)
}, },
onload: function (frm) { onload: function (frm) {
// filter_value = "SOP" // filter_value = "SOP"
// set_default_tab(frm,filter_value) // set_default_tab(frm,filter_value)
setTimeout(function mysam(){ if (!frm.doc.feature_finder_images){
if (!frm.doc.feature_finder_images){ console.log("calling 1")
console.log("calling 1") $(cur_frm.fields_dict.image_html.wrapper).empty();
$(cur_frm.fields_dict.image_html.wrapper).empty(); }
} if (!frm.is_new()) {
if (!frm.is_new()) { custom_tab_html(frm)
custom_tab_html(frm) }
}
},2000)
set_display_order(frm) set_display_order(frm)
// show_images(frm) show_images(frm)
}, },
@ -165,20 +160,19 @@ frappe.ui.form.on('Feature Finder', {
frm.reload_doc() frm.reload_doc()
} }
}); });
// function show_images(frm) { function show_images(frm) {
// var res = $(cur_frm.fields_dict.image_html.wrapper).empty(); var res = $(cur_frm.fields_dict.image_html.wrapper).empty();
// if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0) { if (cur_frm.doc.feature_finder_images && cur_frm.doc.feature_finder_images.length > 0) {
// var img_html = "" var img_html = ""
img_html += "<div style='height: 300px;overflow-y: auto;overflow-x: hidden;border:1px solid var(--table-border-color);margin: 5px 0px 10px 0px;'><div style='padding: 5px;' class='row'>"
// img_html += "<div style='height: 300px;overflow-y: auto;overflow-x: hidden;border:1px solid var(--table-border-color);margin: 5px 0px 10px 0px;'><div style='padding: 5px;' class='row'>" cur_frm.doc.feature_finder_images.forEach((val) =>
// cur_frm.doc.feature_finder_images.forEach((val) => img_html += "<div class='col-3' style='padding-top:13px;'><img src=" + "'" + val.image + "'" + "></div>"
// img_html += "<div class='col-3' style='padding-top:13px;'><img src=" + "'" + val.image + "'" + "></div>"
// ); );
// img_html += "</div></div>" img_html += "</div></div>"
// $(res).append(img_html) $(res).append(img_html)
// } }
// } }
function custom_tab_html(frm) { function custom_tab_html(frm) {
// $('[data-fieldname="specification"]').show() // $('[data-fieldname="specification"]').show()
@ -254,7 +248,6 @@ function custom_tab_html(frm) {
var nav_spec = {} var nav_spec = {}
nav_spec.feature_type = "SOP" nav_spec.feature_type = "SOP"
all_tabs() all_tabs()
show_images()
$('.main').find('.nav-link').click(function (event) { $('.main').find('.nav-link').click(function (event) {
console.log($(this)[0].id) console.log($(this)[0].id)
@ -285,24 +278,10 @@ function custom_tab_html(frm) {
} }
all_tabs() all_tabs()
show_images()
}) })
function show_images(frm) {
var res = $(cur_frm.fields_dict.image_html.wrapper).empty();
if (feature_finder_images.length > 0) {
var img_html = ""
img_html += "<div style='height: 300px;overflow-y: auto;overflow-x: hidden;border:1px solid var(--table-border-color);margin: 5px 0px 10px 0px;'><div style='padding: 5px;' class='row'>"
feature_finder_images.forEach((val) =>
img_html += "<div class='col-3' style='padding-top:13px;'><img src=" + "'" + val.image + "'" + "></div>"
);
img_html += "</div></div>"
$(res).append(img_html)
}
}
function all_tabs() { function all_tabs() {

33
smart_service/phase_2/doctype/publish_test/publish_test.py

@ -48,11 +48,15 @@ class PublishTest(Document):
str(km_mapping.name) + '\n' str(km_mapping.name) + '\n'
def on_submit(self): def on_submit(self):
if self.docstatus==1 and self.publish_status == 'To Publish' and self.publish_module=='Others' and self.publish_type=='Internal': if self.docstatus==1 and self.publish_status == 'To Publish' and self.publish_module=='Others' and self.publish_type=='Internal':
repair_checksheet_publish(self.vehicle,self.vehicle_id,self.language,self.publish_type,self.release_description,self.variant)
# 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)) 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': if self.docstatus==1 and self.publish_module=='Others' and self.publish_type=='Global':
# 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_published_docs(self) update_published_docs(self)
repair_checksheet_publish(self.vehicle,self.vehicle_id,self.language,self.publish_type,self.release_description,self.variant)
@ -429,11 +433,11 @@ def get_service_repair(vehicle, language_label, publish_type):
return data return data
def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_description,variant): def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_description,variant,parent):
try: try:
logger_file=f'{vehicle}-{language}-{publish_type}' logger_file=f'{vehicle}-{language}-{publish_type}'
logger = frappe.logger(logger_file, allow_site=True, file_count=100) logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}') logger.info(f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}-{parent}')
folder_url=base_url+"/"+vehicle.replace(' ', '-') + "/"+language folder_url=base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}') logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
@ -456,12 +460,18 @@ def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_d
'publish_language': language, 'publish_language': language,
'data':'' 'data':''
} }
repair_checksheet=repair_checksheet_data(vehicle,language,publish_type) repair_checksheet_tmp=[]
if repair_checksheet['status']==1: for i in parent:
publish_repair_checksheet=1 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_checksheet_tmp.append(repair_checksheet['data'][0])
if publish_repair_checksheet==1: if publish_repair_checksheet==1:
""" Save publish file """ """ Save publish file """
vehicle_data['data']={'repair_checksheet':repair_checksheet['data']} vehicle_data['data']={'repair_checksheet':repair_checksheet_tmp}
with open(file_path, 'w') as outfile: with open(file_path, 'w') as outfile:
outfile.write(json.dumps(vehicle_data,indent=4,default=str)) outfile.write(json.dumps(vehicle_data,indent=4,default=str))
else: else:
@ -480,8 +490,9 @@ def update_published_docs(self):
if self.repair_checksheet_publish: if self.repair_checksheet_publish:
try: try:
for d in self.repair_checksheet_publish: for d in self.repair_checksheet_publish:
frappe.db.sql( frappe.db.sql(
"""UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(d.parent_name)) """UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(i.parent_name))
frappe.db.commit() frappe.db.commit()
except Exception as e: except Exception as e:
frappe.throw(str(e)) frappe.throw(str(e))
@ -504,13 +515,13 @@ def create_publish_folders(folder_url):
frappe.throw(str(e)) frappe.throw(str(e))
return False return False
def repair_checksheet_data(vehicle=None,language=None,publish_type=None): def repair_checksheet_data(vehicle=None,language=None,publish_type=None,parent=None):
try: try:
logger_file=f'{vehicle}-{language}-{publish_type}' logger_file=f'{vehicle}-{language}-{publish_type}'
logger = frappe.logger(logger_file, allow_site=True, file_count=100) logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(f"start of fetching repair checksheet data-{vehicle}-{language}") 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 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'""", as_dict=1) `tabRepair Service Mapping` where vehicle = '{vehicle}' and language = '{language}' and active_status='Active' and name='{parent}'""", as_dict=1)
for d in repair_service_details: 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` 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) where parent = '{d['name']}' order by display_order ;""", as_dict=1)

Loading…
Cancel
Save