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. 2
      smart_service/phase_2/doctype/feature_finder/feature_finder.py
  4. 11
      smart_service/phase_2/doctype/publish_test/publish_test.js
  5. 4
      smart_service/phase_2/doctype/publish_test/publish_test.json
  6. 74
      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', { frappe.ui.form.on('Feature Finder', {
refresh: function (frm) { refresh: function (frm) {
// filter_value = "SOP"
// set_default_tab(frm,filter_value)
if (!frm.doc.feature_finder_images){ if (!frm.doc.feature_finder_images){
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)
} }
set_display_order(frm) set_display_order(frm)
show_images(frm) show_images(frm)
}, },
onload: function (frm) { onload: function (frm) {
// filter_value = "SOP"
// set_default_tab(frm,filter_value)
if (!frm.doc.feature_finder_images){ if (!frm.doc.feature_finder_images){
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)
} }
set_display_order(frm) set_display_order(frm)
show_images(frm) show_images(frm)
@ -57,7 +48,7 @@ frappe.ui.form.on('Feature Finder', {
features_names: function (frm) { features_names: function (frm) {
frappe.db.get_list('Feature Finder Master', { frappe.db.get_list('Feature Finder Master', {
fields: ['name'], fields: ['name','feature_category'],
filters: { filters: {
feature_name: frm.doc.features_names, feature_name: frm.doc.features_names,
vehicle: frm.doc.vehicle vehicle: frm.doc.vehicle
@ -66,10 +57,14 @@ frappe.ui.form.on('Feature Finder', {
console.log(records) console.log(records)
if(records.length>0){ if(records.length>0){
frm.doc.feature_name = records[0].name 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_name")
cur_frm.refresh_fields("feature_category")
}else{ }else{
frm.doc.feature_name = "" frm.doc.feature_name = ""
frm.doc.feature_category =""
cur_frm.refresh_fields("feature_name") 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" "options": "Feature Finder Specification"
}, },
{ {
"depends_on": "eval:doc.feature_name",
"fetch_from": "feature_name.feature_category", "fetch_from": "feature_name.feature_category",
"fieldname": "feature_category", "fieldname": "feature_category",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Feature Category" "label": "Feature Category"
}, },
{ {
"depends_on": "eval:doc.variant!=\"\"", "depends_on": "eval:doc.variant",
"fieldname": "features_names", "fieldname": "features_names",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Feature Name", "label": "Feature Name",
@ -173,7 +174,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-08-09 12:50:40.680301", "modified": "2023-08-10 10:50:41.774687",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Phase-2", "module": "Phase-2",
"name": "Feature Finder", "name": "Feature Finder",

2
smart_service/phase_2/doctype/feature_finder/feature_finder.py

@ -81,7 +81,7 @@ def get_feature_list(vehicle, language):
f"""select feature_name from `tabFeature Finder Master` where vehicle='{vehicle}' and language = '{language}';""", as_list=1) f"""select feature_name from `tabFeature Finder Master` where vehicle='{vehicle}' and language = '{language}';""", as_list=1)
return features_list return features_list
@frappe.whitelist() @frappe.whitelist()
def get_list_data(name, val): def get_list_data(name, val):
specification = frappe.db.sql( specification = frappe.db.sql(

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 name: frm.doc.name
}, },
callback: function (r) { callback: function (r) {
debugger
if (r.message.status == "success") { 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 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 //check for atleast one data to publish
if(frm.doc.publish_module=='Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')){ if(frm.doc.publish_module=='Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')){
debugger
frappe.throw('No Data Found To Publish') frappe.throw('No Data Found To Publish')
@ -569,6 +565,11 @@ frappe.ui.form.on('Publish Test', {
km_report: function (frm, cdt, cdn) { km_report: function (frm, cdt, cdn) {
frappe.set_route("query-report", 'Kilometer Mapping', { 'kilometer_mapping': frm.doc.kilometer_mapping }); 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) { vehicle: function (frm) {
frappe.call({ frappe.call({

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

@ -175,7 +175,7 @@
"fieldtype": "Column Break" "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", "fieldname": "variant_mapping",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Variant Mapping", "label": "Variant Mapping",
@ -327,7 +327,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2023-08-08 10:29:25.863957", "modified": "2023-08-10 11:22:21.366394",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Phase-2", "module": "Phase-2",
"name": "Publish Test", "name": "Publish Test",

74
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-bench/sites/" + site_name + "/public"+"/json_files"+"/Other_Module"
frappe.utils.logger.set_log_level("DEBUG") frappe.utils.logger.set_log_level("DEBUG")
success_reponse={"status":1,"data":"","message":""} success_reponse={"status":1,"data":"","message":""}
failure_reponse={"status":0,"data":"","error":""} failure_reponse={"status":0,"data":"","error":""}
class PublishTest(Document): class PublishTest(Document):
def validate(self): def validate(self):
self.published_date = str(date.today()) self.published_date = str(date.today())
@ -48,9 +47,6 @@ 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':
# 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) 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':
@ -425,7 +421,7 @@ def update_procedure_value(name, file_path):
frappe.db.commit() frappe.db.commit()
@ frappe.whitelist() @frappe.whitelist()
def get_service_repair(vehicle, language_label, publish_type): def get_service_repair(vehicle, language_label, publish_type):
data = frappe.db.sql(f''' data = frappe.db.sql(f'''
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0; 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 Folder For Publish'''
create_publish_folders(folder_url) create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + vehicle.replace(' ', file_path = folder_url + "/" + publish_type + "/" + vehicle.replace(' ',
'-') +'.json' '-')+'-repair_check_sheet' +'.json'
try: # try:
'''Append Published Data to Json''' '''Append Published Data to Json'''
logger.info(f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}') logger.info(f'Repair Checksheet Data Append Start::{vehicle}-{language}-{publish_type}')
vehicle_data = { vehicle_data = {
'vehicle': vehicle, 'vehicle': vehicle,
'vehicle_myid': vehicle_id, 'vehicle_myid': vehicle_id,
'publish_type': publish_type, 'publish_type': publish_type,
'publish_description': release_description, 'publish_description': release_description,
'publish_language': language, 'publish_language': language,
'data':'' 'data':''
} }
repair_checksheet_tmp=[] repair_checksheet_tmp=[]
for i in parent: for i in parent:
frappe.msgprint(str(i.parent_name)) repair_checksheet=repair_checksheet_data(vehicle,language,publish_type,i.parent_name)
repair_checksheet=repair_checksheet_data(vehicle,language,publish_type,i.parent_name) if repair_checksheet['status']==1:
frappe.msgprint(str(repair_checksheet)) publish_repair_checksheet=1
if repair_checksheet['status']==1: if len(repair_checksheet['data']):
publish_repair_checksheet=1
repair_checksheet_tmp.append(repair_checksheet['data'][0]) 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))
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')
return 1,file_path return 1,file_path
except Exception as e: # except Exception as e:
logger.info(f'{vehicle}-{language}-{publish_type} error in json creation'+str(e)) # logger.info(f'{vehicle}-{language}-{publish_type} error in json creation'+str(e))
return e # frappe.throw('Failed To Publish')
# return e
except Exception as e: except Exception as e:
return e frappe.throw('Failed To Publish')
def update_published_docs(self): def update_published_docs(self):
try: try:
if self.repair_checksheet_publish: if self.repair_checksheet_publish:
@ -492,7 +488,7 @@ def update_published_docs(self):
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(i.parent_name)) """UPDATE `tabRepair Service Mapping` set published=1 where name='{0}'""".format(d.parent_name))
frappe.db.commit() frappe.db.commit()
except Exception as e: except Exception as e:
frappe.throw(str(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 = 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' 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: 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