diff --git a/smart_service/apis/v2/master.py b/smart_service/apis/v2/master.py index 8204891..03b6e3a 100644 --- a/smart_service/apis/v2/master.py +++ b/smart_service/apis/v2/master.py @@ -77,7 +77,7 @@ def get_feature_finder(vehicle, variant, language): ffm.feature_pdf as pdf from `tabFeature Finder` ff left join `tabFeature Finder Master` ffm on ff.features_names = ffm.feature_name where ff.vehicle = "{vehicle}" and ffm.vehicle = "{vehicle}" and ff.variant = "{variant}" - and ff.language = "{language}"; + and ff.language = "{language}" and ffm.language = "{language}"; """, as_dict=1) else: feature_finder_details = frappe.db.sql(f"""select ff.name,ff.vehicle,ff.vehicle_id,ff.variant,ff.variant_id,ff.language, diff --git a/smart_service/masters/doctype/role_master/role_master.json b/smart_service/masters/doctype/role_master/role_master.json index f1c48a0..f6424bb 100644 --- a/smart_service/masters/doctype/role_master/role_master.json +++ b/smart_service/masters/doctype/role_master/role_master.json @@ -15,7 +15,8 @@ "active_status", "display_order", "my_id", - "modules" + "modules", + "skill_id" ], "fields": [ { @@ -67,11 +68,16 @@ "fieldtype": "Small Text", "hidden": 1, "label": "Modules" + }, + { + "fieldname": "skill_id", + "fieldtype": "Data", + "label": "Skill Id" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-07-21 15:15:43.988229", + "modified": "2023-08-14 12:33:27.319600", "modified_by": "Administrator", "module": "Masters", "name": "Role Master", diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.js b/smart_service/phase_2/doctype/feature_finder/feature_finder.js index 5487308..cf92ed4 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.js +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.js @@ -139,6 +139,12 @@ frappe.ui.form.on('Feature Finder', { } }); } + + // var specifiaction_data = $('.spec-table').find('tr').find('input[type="text"]'); + // console.log(specifiaction_data,"specifiaction_data") + // specifiaction_data.each(function(){ + // console.log($(this).val()) + // }); }, after_save: function (frm) { cur_frm.refresh_fields("display_order") @@ -179,9 +185,10 @@ function custom_tab_html(frm) { res.append(ret) - $(res).find('.main').append(`
`) - $(res).find('.main').append(`
`) $(res).find('.main').append(`
`) + $(res).find('.main').append(`
`) + $(res).find('.main').append(`
`) + res.append(``) @@ -206,6 +213,7 @@ function custom_tab_html(frm) { var content_dialog_value = "" var nav_spec = {} nav_spec.feature_type = "SOP" + nav_spec.active_status = "Active" all_tabs() $('.main').find('.nav-link').click(function (event) { @@ -243,14 +251,14 @@ function custom_tab_html(frm) { //heading var spec_custom_dt = "" - spec_custom_dt += ` + spec_custom_dt += `
- +
No Specification Value Active StatusFeature TypePost Vin CutOff Name @@ -261,13 +269,13 @@ function custom_tab_html(frm) { var image_custom_dt = "" - image_custom_dt += ` + image_custom_dt += `
- +
No Image Active StatusFeature TypePost Vin CutOff Name @@ -278,13 +286,13 @@ function custom_tab_html(frm) { var content_custom_dt = "" - content_custom_dt += ` + content_custom_dt += `
- + ' image_custom_dt += '' - image_custom_dt += '' + // image_custom_dt += '' if (val.post_vin_cutoff_name) { image_custom_dt += '' } @@ -362,7 +370,7 @@ function custom_tab_html(frm) { content_custom_dt += '' content_custom_dt += '' content_custom_dt += '' - content_custom_dt += '' + // content_custom_dt += '' if (val.post_vin_cutoff_name) { content_custom_dt += '' } @@ -409,26 +417,28 @@ function custom_tab_html(frm) { image_custom_dt += '' content_custom_dt += '' - $(res).find('.specification_bl').empty() - $(res).find('.specification_bl').append(spec_custom_dt) + + + $(res).find('.feature_contbl').empty() + $(res).find('.feature_contbl').append(content_custom_dt) $(res).find('.feature_imgbl').empty() $(res).find('.feature_imgbl').append(image_custom_dt) - $(res).find('.feature_contbl').empty() - $(res).find('.feature_contbl').append(content_custom_dt) + $(res).find('.specification_bl').empty() + $(res).find('.specification_bl').append(spec_custom_dt) if(nav_spec.feature_type=='SOP'){ $(res).find('#postvin1').hide() $(res).find('#postvin2').hide() $(res).find('#postvin3').hide() } - $(res).append(``) + $(res).append(``) - $(res).append(``) - $(res).append(``) //append end @@ -461,7 +471,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) }) }) @@ -665,6 +675,56 @@ function custom_tab_html(frm) { }) //delete function end + // $(function () { + + // // Start counting from the third row + // var counter = 3; + + // $(".spec_custom_add").on("click", function (event) { + // event.preventDefault(); + + // var newRow = $(''); + // var cols = ''; + + + // frappe.call({ + // method: "smart_service.phase_2.doctype.feature_finder.feature_finder.get_specification_list", + // args: { + + // }, + // callback: function (r) { + // if (r.message) { + // console.log("calling") + // cols += '' + // // cols += ''; + // cols += '' + // cols += ''; + // cols += ''; + // // cols += '' + // newRow.append(cols); + // $(".spec-table").append(newRow); + // $(res).find('.specification_bl').find('.spec_custom_save').css('display','inline-block') + // counter++; + // } + // } + // }) + + + // }); + + // // Remove row when delete btn is clicked + // $(".spec-table").on("click", "#deleteRow", function (event) { + // $(this).closest("tr").remove(); + // counter -= 1 + // }); + // }); + } function spec_dialog_view() { @@ -684,7 +744,13 @@ function custom_tab_html(frm) { fieldname: 'specification', fieldtype: 'Link', options: "Feature Finder Specification Master", - default: spec_dialog_value.specification + default: spec_dialog_value.specification, + get_query() { + return { + filters: { 'Active Status': 'Active' } + } + } + }, { label: 'Value', @@ -704,7 +770,8 @@ function custom_tab_html(frm) { fieldname: 'feature_type', fieldtype: 'Data', default: spec_dialog_value.feature_type, - read_only: 1 + read_only: 1, + hidden:1 }, { label: 'Post Vin Cutoff Name', @@ -771,7 +838,8 @@ function custom_tab_html(frm) { fieldname: 'feature_type', fieldtype: 'Data', default: image_dialog_value.feature_type, - read_only: 1 + read_only: 1, + hidden:1 }, { label: 'Post Vin Cutoff Name', @@ -839,7 +907,8 @@ function custom_tab_html(frm) { fieldname: 'feature_type', fieldtype: 'Data', default: content_dialog_value.feature_type, - read_only: 1 + read_only: 1, + hidden:1 }, { label: 'Post Vin Cutoff Name', diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.json b/smart_service/phase_2/doctype/feature_finder/feature_finder.json index 890627e..f75fd2a 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.json +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.json @@ -1,6 +1,6 @@ { "_comments": "[]", - "_liked_by": "[]", + "_liked_by": "[\"Administrator\"]", "actions": [], "allow_rename": 1, "autoname": "format:{variant}-{features_names}-{language}", @@ -116,6 +116,8 @@ { "fieldname": "active_status", "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, "label": "Active Status", "options": "Active\nIn Active" }, @@ -131,12 +133,17 @@ "fetch_from": "feature_name.feature_category", "fieldname": "feature_category", "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, "label": "Feature Category" }, { "depends_on": "eval:doc.variant", "fieldname": "features_names", "fieldtype": "Select", + "in_global_search": 1, + "in_list_view": 1, + "in_standard_filter": 1, "label": "Feature Name", "reqd": 1, "set_only_once": 1 @@ -187,7 +194,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-10 13:41:34.327348", + "modified": "2023-08-14 17:49:28.825452", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder", diff --git a/smart_service/phase_2/doctype/feature_finder/feature_finder.py b/smart_service/phase_2/doctype/feature_finder/feature_finder.py index c417c32..c074f37 100644 --- a/smart_service/phase_2/doctype/feature_finder/feature_finder.py +++ b/smart_service/phase_2/doctype/feature_finder/feature_finder.py @@ -228,3 +228,10 @@ def set_display_order(doctype_name, values): return {"status": "success"} except Exception as e: frappe.log_error("set_display_order", str(e)) + + + +@frappe.whitelist() +def get_specification_list(): + res = frappe.db.sql("""select name from `tabFeature Finder Specification Master`""",as_dict=1) + return res \ No newline at end of file diff --git a/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js b/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js index ae0caf5..d3eafe2 100644 --- a/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js +++ b/smart_service/phase_2/doctype/feature_finder_category_master/feature_finder_category_master.js @@ -16,7 +16,6 @@ function check_field_character(field_name) { frappe.validated = false; } else { if (alphanum.test(field_name) === true) { - frappe.validated = true; } else if (field_name) { frappe.throw(__("Feature Finder Category Master: Enter letter or alpha numeric characters only.")); frappe.validated = false; diff --git a/smart_service/phase_2/doctype/feature_finder_publish_data/__init__.py b/smart_service/phase_2/doctype/feature_finder_publish_data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json b/smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json new file mode 100644 index 0000000..642f1f5 --- /dev/null +++ b/smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.json @@ -0,0 +1,124 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2023-08-10 22:37:14.844640", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "is_published", + "variant", + "language", + "display_order", + "active_status", + "column_break_mmuuc", + "vehicle", + "feature_name", + "features_names", + "feature_category", + "vehicle_id", + "variant_id" + ], + "fields": [ + { + "default": "0", + "fieldname": "is_published", + "fieldtype": "Check", + "label": "Published", + "read_only": 1 + }, + { + "fieldname": "variant", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Variant", + "options": "Variant Mapping", + "set_only_once": 1 + }, + { + "fieldname": "language", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Language", + "options": "Custom Languages", + "set_only_once": 1 + }, + { + "fieldname": "display_order", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Display Order", + "read_only_depends_on": "eval:doc.language!=\"en\"" + }, + { + "fieldname": "active_status", + "fieldtype": "Select", + "label": "Active Status", + "options": "Active\nIn Active" + }, + { + "fieldname": "column_break_mmuuc", + "fieldtype": "Column Break" + }, + { + "fetch_from": "variant.vehicle", + "fieldname": "vehicle", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Vehicle", + "read_only": 1 + }, + { + "depends_on": "eval:doc.variant!=\"\"", + "fieldname": "feature_name", + "fieldtype": "Link", + "hidden": 1, + "label": "Feature Name1", + "options": "Feature Finder Master", + "read_only": 1, + "set_only_once": 1 + }, + { + "depends_on": "eval:doc.variant", + "fieldname": "features_names", + "fieldtype": "Data", + "label": "Feature Name", + "set_only_once": 1 + }, + { + "depends_on": "eval:doc.feature_name", + "fetch_from": "feature_name.feature_category", + "fieldname": "feature_category", + "fieldtype": "Data", + "label": "Feature Category" + }, + { + "fetch_from": "variant.vehicle_id", + "fieldname": "vehicle_id", + "fieldtype": "Int", + "hidden": 1, + "label": "Vehicle Id" + }, + { + "fetch_from": "variant.name", + "fieldname": "variant_id", + "fieldtype": "Data", + "hidden": 1, + "label": "Variant Id" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2023-08-10 22:37:14.844640", + "modified_by": "Administrator", + "module": "Phase-2", + "name": "Feature Finder Publish Data", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC" +} \ No newline at end of file diff --git a/smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.py b/smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_publish_data.py new file mode 100644 index 0000000..aeaf1d0 --- /dev/null +++ b/smart_service/phase_2/doctype/feature_finder_publish_data/feature_finder_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 FeatureFinderPublishData(Document): + pass diff --git a/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json b/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json index 261d5df..a889863 100644 --- a/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json +++ b/smart_service/phase_2/doctype/feature_finder_specification_master/feature_finder_specification_master.json @@ -1,4 +1,5 @@ { + "_liked_by": "[\"Administrator\"]", "actions": [], "allow_rename": 1, "autoname": "format:{specification}", @@ -22,6 +23,8 @@ { "fieldname": "active_status", "fieldtype": "Select", + "in_list_view": 1, + "in_standard_filter": 1, "label": "Active Status", "options": "Active\nInactive" }, @@ -35,7 +38,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-10 12:46:14.322512", + "modified": "2023-08-14 17:46:12.062394", "modified_by": "Administrator", "module": "Phase-2", "name": "Feature Finder Specification Master", diff --git a/smart_service/phase_2/doctype/publish_test/publish_test.js b/smart_service/phase_2/doctype/publish_test/publish_test.js index 4aacc12..a77305b 100644 --- a/smart_service/phase_2/doctype/publish_test/publish_test.js +++ b/smart_service/phase_2/doctype/publish_test/publish_test.js @@ -10,35 +10,25 @@ cur_frm.fields_dict['variant_mapping'].get_query = function (doc, cdt, cdn) { } }; }; -var selected_module='' +var selected_module = '' cur_frm.fields_dict['vehicle'].get_query = function (doc, cdt, cdn) { return { query: "smart_service.masters.doctype.vehicle.vehicle.vehicle_filter", }; }; let lang_set_first_time = true; frappe.ui.form.on('Publish Test', { - // publish_module:function(frm){ - // if(frm.doc.publish_module=='Automotive'){ - // selected_module=1 - // } - // else{ - // selected_module=0 - - // } - - // }, onload: function (frm) { // $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish") - if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') { + if (frm.doc.docstatus == 0 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module == 'Others') { $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Internal Publish") } - if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global"&& frm.doc.publish_module=='Others') { + if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global" && frm.doc.publish_module == 'Others') { $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish") } - if(frm.doc.status="Published" && frm.doc.publish_module=='Others'){ - frm.set_df_property('repair_checksheet_publish','hidden',0) + if (frm.doc.status = "Published" && frm.doc.publish_module == 'Others') { + frm.set_df_property('repair_checksheet_publish', 'hidden', 0) frm.refresh_field('repair_checksheet_publish') @@ -86,252 +76,252 @@ frappe.ui.form.on('Publish Test', { if (frm.doc.docstatus == 0 && frm.doc.publish_type == "Global") { $('[data-route="Form/Publish Test/' + frm.doc.name + '"]').find('.primary-action').html("Global Publish") } - if(frm.doc.publish_module=='Automotive'){ + if (frm.doc.publish_module == 'Automotive') { 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-insert-row').hide(); - cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-append-row').hide(); - frm.fields_dict.system_mapping.grid.wrapper.find('.grid-append-row').hide(); + 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-insert-row').hide(); + cur_frm.fields_dict['system_mapping'].grid.wrapper.find('.grid-append-row').hide(); + frm.fields_dict.system_mapping.grid.wrapper.find('.grid-append-row').hide(); + + cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-add-row').hide(); + cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-upload').hide(); + cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-remove-rows').hide(); + cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-insert-row').hide(); + cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-append-row').hide(); + frm.fields_dict.variant_mapping_assets.grid.wrapper.find('.grid-append-row').hide(); + + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-add-row').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-upload').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-all-rows').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-rows').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete-row').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete_all_rows').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-move-row').hide(); + cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-append-row').hide(); + frm.fields_dict.publish_documents.grid.wrapper.find('.grid-append-row').hide(); + + document.querySelectorAll("[data-fieldname='km_report']")[1].style.backgroundColor = "#e31a37"; + document.querySelectorAll("[data-fieldname='km_report']")[1].style.color = "#FFFFFF"; + document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.backgroundColor = "#e31a37"; + document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.color = "#FFFFFF"; + if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) { + frappe.call({ + method: "smart_service.transactions.doctype.publish.publish.max_publish", + args: { + "doc": frm.doc.name, + }, + callback: function (r) { + if (r.message) { + if (r.message == frm.doc.version) { + frm.add_custom_button(__('Global Publish'), function () { + frappe.call({ + method: "smart_service.transactions.doctype.publish.publish.global_publish", + args: { + "doc": frm.doc.name, + }, + callback: function (r) { + cur_frm.reload_doc(); + } + }); + }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' }); + } + } + } + }) + } - cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-add-row').hide(); - cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-upload').hide(); - cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-remove-rows').hide(); - cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-insert-row').hide(); - cur_frm.fields_dict['variant_mapping_assets'].grid.wrapper.find('.grid-append-row').hide(); - frm.fields_dict.variant_mapping_assets.grid.wrapper.find('.grid-append-row').hide(); - - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-add-row').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-upload').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-all-rows').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-remove-rows').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete-row').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-delete_all_rows').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-move-row').hide(); - cur_frm.fields_dict['publish_documents'].grid.wrapper.find('.grid-append-row').hide(); - frm.fields_dict.publish_documents.grid.wrapper.find('.grid-append-row').hide(); - - document.querySelectorAll("[data-fieldname='km_report']")[1].style.backgroundColor = "#e31a37"; - document.querySelectorAll("[data-fieldname='km_report']")[1].style.color = "#FFFFFF"; - document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.backgroundColor = "#e31a37"; - document.querySelectorAll("[data-fieldname='add_variant_mapping_to_publish']")[1].style.color = "#FFFFFF"; - if (frm.doc.docstatus === 1 && frm.doc.publish_type == "Internal" && frm.doc.publish_status == 'Published' && !frm.doc.global_publish && frappe.user.has_role('_Publisher')) { - frappe.call({ - method: "smart_service.transactions.doctype.publish.publish.max_publish", - args: { - "doc": frm.doc.name, - }, - callback: function (r) { - if (r.message) { - if (r.message == frm.doc.version) { - frm.add_custom_button(__('Global Publish'), function () { + + if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher')) { + frm.add_custom_button(__('Publish'), function () { + frappe.confirm('Are you sure you want to Publish?', + () => { + // action to perform if Yes is selected + if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type) { frappe.call({ - method: "smart_service.transactions.doctype.publish.publish.global_publish", + method: 'smart_service.transactions.doctype.publish.publish.cal_ver', args: { - "doc": frm.doc.name, + vehicle: frm.doc.vehicle, + lang: frm.doc.language, + publish_type: frm.doc.publish_type, + doc: frm.doc.name }, - callback: function (r) { - cur_frm.reload_doc(); + callback: (r) => { + frm.set_value('version', r.message); + cur_frm.refresh_field('version') + if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') { + frappe.call({ + // method: "smart_service.apis.publish_api.api_procedure", + method: "smart_service.apis.publish_api.new_publish", + args: { + "args": frm.doc.name, + "publish_type": frm.doc.publish_type, + "vehicle": frm.doc.vehicle, + "language": frm.doc.language, + "version": frm.doc.version + }, + callback: function (r) { + // if (r.message[0]) { + frm.set_value('publish_status', 'Published'); + frm.page.clear_primary_action("Publish"); + frm.set_value('actual_published_date', frappe.datetime.nowdate()); + frappe.call({ + method: "smart_service.transactions.doctype.publish.publish.update_procedure_value", + args: { + "name": frm.doc.name, + "file_path": r.message[1], + }, + callback: (r) => { + // frm.save('Update'); + } + }) + frappe.msgprint({ + title: __('Notification'), + message: __('Successfully Published: ' + r.message[1]), + primary_action: { + action(values) { + frm.save('Update'); + } + } + }); + // } + // else { + // frappe.msgprint({ + // title: __('Notification'), + // message: __('Not Successfully Published: ' + r.message[1]), + // // primary_action: { + // // action(values) { + // // frm.save('Update'); + // // } + // // } + // }); + // } + + + // if (r.message != "Failed to save file") { + // frm.set_value('publish_status', 'Published'); + // frm.set_value('actual_published_date', frappe.datetime.nowdate()); + // frappe.call({ + // method: "smart_service.transactions.doctype.publish.publish.update_procedure_value", + // args: { + // "name": frm.doc.name, + // "file_path": r.message, + // }, + // callback: (r) => { + // // frm.save('Update'); + // } + // }) + // frappe.msgprint({ + // title: __('Notification'), + // message: __('Successfully Published: ' + r.message), + // primary_action: { + // action(values) { + // frm.save('Update'); + // } + // } + // }); + // } else { + // frappe.msgprint('Publish Failed') + // } + } + }); + } + }, + }) + } + }, () => { + // action to perform if No is selected + }); + }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' }); + } else if (frm.doc.publish_status == 'Published') { + frm.set_read_only(); + frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1); + } + + + + if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') { + frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () { + let added = 0; + let topublish = []; + if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; } + frm.doc.system_mapping.forEach(row => { + if (topublish.indexOf(row.procedure_status) > -1) { + let dulicate = false; + if (frm.doc.publish_documents) { + frm.doc.publish_documents.forEach(publishrow => { + if (frm.doc.variant_mapping == publishrow.variant_mapping && + row.systems == publishrow.system && + row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) { + dulicate = true; } }); - }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' }); + } + if (dulicate === false) { + let child = cur_frm.add_child("publish_documents"); + child.variant_mapping = frm.doc.variant_mapping; + child.system = row.systems; + child.sub_system = row.sub_systems; + child.procedure_link = row.procedure; + child.procedure_status = row.procedure_status; + child.update_procedure_status = row.procedure_status; + child.item_category = "System Mapping"; + child.variant = frm.doc.variant; + refresh_field("publish_documents"); + added += 1; + } } - } - } - }) - } + }); + if (added) { frappe.msgprint(__(added + " Doc(s) Added")); } + else { frappe.msgprint(__("No Doc Added")); } + }); + frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary'); - if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher')) { - frm.add_custom_button(__('Publish'), function () { - frappe.confirm('Are you sure you want to Publish?', - () => { - // action to perform if Yes is selected - if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type) { - frappe.call({ - method: 'smart_service.transactions.doctype.publish.publish.cal_ver', - args: { - vehicle: frm.doc.vehicle, - lang: frm.doc.language, - publish_type: frm.doc.publish_type, - doc: frm.doc.name - }, - callback: (r) => { - frm.set_value('version', r.message); - cur_frm.refresh_field('version') - if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish') { - frappe.call({ - // method: "smart_service.apis.publish_api.api_procedure", - method: "smart_service.apis.publish_api.new_publish", - args: { - "args": frm.doc.name, - "publish_type": frm.doc.publish_type, - "vehicle": frm.doc.vehicle, - "language": frm.doc.language, - "version": frm.doc.version - }, - callback: function (r) { - // if (r.message[0]) { - frm.set_value('publish_status', 'Published'); - frm.page.clear_primary_action("Publish"); - frm.set_value('actual_published_date', frappe.datetime.nowdate()); - frappe.call({ - method: "smart_service.transactions.doctype.publish.publish.update_procedure_value", - args: { - "name": frm.doc.name, - "file_path": r.message[1], - }, - callback: (r) => { - // frm.save('Update'); - } - }) - frappe.msgprint({ - title: __('Notification'), - message: __('Successfully Published: ' + r.message[1]), - primary_action: { - action(values) { - frm.save('Update'); - } - } - }); - // } - // else { - // frappe.msgprint({ - // title: __('Notification'), - // message: __('Not Successfully Published: ' + r.message[1]), - // // primary_action: { - // // action(values) { - // // frm.save('Update'); - // // } - // // } - // }); - // } - - - // if (r.message != "Failed to save file") { - // frm.set_value('publish_status', 'Published'); - // frm.set_value('actual_published_date', frappe.datetime.nowdate()); - // frappe.call({ - // method: "smart_service.transactions.doctype.publish.publish.update_procedure_value", - // args: { - // "name": frm.doc.name, - // "file_path": r.message, - // }, - // callback: (r) => { - // // frm.save('Update'); - // } - // }) - // frappe.msgprint({ - // title: __('Notification'), - // message: __('Successfully Published: ' + r.message), - // primary_action: { - // action(values) { - // frm.save('Update'); - // } - // } - // }); - // } else { - // frappe.msgprint('Publish Failed') - // } - } - }); + } + if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') { + frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () { + let added = 0; + frm.doc.variant_mapping_assets.forEach(row => { + if (row.active_status == "Active" || row.active_status == "Inactive") { + let dulicate = false; + if (frm.doc.publish_documents) { + frm.doc.publish_documents.forEach(publishrow => { + if (frm.doc.variant_mapping == publishrow.variant_mapping && + row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) { + dulicate = true; } - }, - }) + }); + } + if (dulicate === false) { + let child = cur_frm.add_child("publish_documents"); + child.variant_mapping = frm.doc.variant_mapping; + child.asset_category = row.category; + child.item_category = "Variant Mapping Assets"; + child.variant = frm.doc.variant; + child.attach_file = row.attach_file; + refresh_field("publish_documents"); + added += 1; + } } - }, () => { - // action to perform if No is selected }); - }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' }); - } else if (frm.doc.publish_status == 'Published') { - frm.set_read_only(); - frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1); - } - - - - if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') { - frm.get_field('system_mapping').grid.add_custom_button(__('Add to Publish'), function () { - let added = 0; - let topublish = []; - if (frm.doc.publish_type == 'Global') { topublish = ['Publish Ready']; } else { topublish = ['Review Pending', 'Publish Ready', 'Approval Pending']; } - frm.doc.system_mapping.forEach(row => { - if (topublish.indexOf(row.procedure_status) > -1) { - let dulicate = false; - if (frm.doc.publish_documents) { - frm.doc.publish_documents.forEach(publishrow => { - if (frm.doc.variant_mapping == publishrow.variant_mapping && - row.systems == publishrow.system && - row.sub_systems == publishrow.sub_system && row.procedure == publishrow.procedure_link) { - dulicate = true; - } - }); - } - if (dulicate === false) { - let child = cur_frm.add_child("publish_documents"); - child.variant_mapping = frm.doc.variant_mapping; - child.system = row.systems; - child.sub_system = row.sub_systems; - child.procedure_link = row.procedure; - child.procedure_status = row.procedure_status; - child.update_procedure_status = row.procedure_status; - child.item_category = "System Mapping"; - child.variant = frm.doc.variant; - refresh_field("publish_documents"); - added += 1; - } - } + if (added) { frappe.msgprint(__(added + " Doc(s) Added")); } + else { frappe.msgprint(__("No Doc Added")); } }); - if (added) { frappe.msgprint(__(added + " Doc(s) Added")); } - else { frappe.msgprint(__("No Doc Added")); } - }); - frm.fields_dict.system_mapping.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary'); + frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary'); + } + if (frm.doc.docstatus == 1) { + $(".grid-buttons").hide(); - } - if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish') { - frm.get_field('variant_mapping_assets').grid.add_custom_button(__('Add to Publish'), function () { - let added = 0; - frm.doc.variant_mapping_assets.forEach(row => { - if (row.active_status == "Active" || row.active_status == "Inactive") { - let dulicate = false; - if (frm.doc.publish_documents) { - frm.doc.publish_documents.forEach(publishrow => { - if (frm.doc.variant_mapping == publishrow.variant_mapping && - row.category == publishrow.asset_category && row.attach_file == publishrow.attach_file) { - dulicate = true; - } - }); - } - if (dulicate === false) { - let child = cur_frm.add_child("publish_documents"); - child.variant_mapping = frm.doc.variant_mapping; - child.asset_category = row.category; - child.item_category = "Variant Mapping Assets"; - child.variant = frm.doc.variant; - child.attach_file = row.attach_file; - refresh_field("publish_documents"); - added += 1; - } - } - }); - if (added) { frappe.msgprint(__(added + " Doc(s) Added")); } - else { frappe.msgprint(__("No Doc Added")); } - }); + } - frm.fields_dict.variant_mapping_assets.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary'); } - if (frm.doc.docstatus == 1) { - $(".grid-buttons").hide(); - } + if (frm.doc.docstatus == 1 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module == 'Others') { + - } - - if (frm.doc.docstatus == 1 && !frm.is_new() && frm.doc.publish_type != "Global" && frm.doc.publish_module=='Others') { - - frm.add_custom_button(__('Global Publish'), function () { frappe.call({ method: "smart_service.phase_2.doctype.publish_test.publish_test.generate_global_publish", @@ -340,7 +330,7 @@ frappe.ui.form.on('Publish Test', { }, callback: function (r) { if (r.message.status == "success") { - + window.location.href = r.message.url + "/app/publish-test" + "/" + r.message.message } } @@ -348,62 +338,17 @@ frappe.ui.form.on('Publish Test', { }).addClass("btn-primary"); } - // if (frm.doc.docstatus === 1 && frm.doc.publish_status == 'To Publish' && frappe.user.has_role('_Publisher') && frm.doc.publish_module=='Others') { - - // frm.add_custom_button(__('Global Publish'), function () { - // frappe.confirm('Are you sure you want to Publish?', - // () => { - // // action to perform if Yes is selected - // if (frm.doc.vehicle && frm.doc.language && frm.doc.publish_type) { - // frappe.call({ - // method: 'smart_service.phase_2.doctype.publish_test.publish_test.repair_checksheet_publish', - // args: { - // vehicle: frm.doc.vehicle, - // language: frm.doc.language, - // publish_type: frm.doc.publish_type, - // release_description:frm.doc.release_description, - // vehicle_id:frm.doc.vehicle_id, - // variant:frm.doc.variant_mapping - - // }, - // callback: (r) => { - - // if(r.message[0]==1){ - // frappe.msgprint({ - // title: __('Notification'), - // message: __('Successfully Published: ' + r.message[1]), - // primary_action: { - // action(values) { - // frm.save('Update'); - // } - // } - // }); - - // } - - // }, - // }) - // } - // }, () => { - // // action to perform if No is selected - // }); - // }).addClass("btn-warning").css({ 'background-color': '#f5b0cd', 'color': 'black' }); - // } else if (frm.doc.publish_status == 'Published') { - // frm.set_read_only(); - // // frm.set_df_property('add_variant_mapping_to_publish', 'hidden', 1); - // } - - + }, validate: function (frm) { - if(frm.doc.publish_module=='Automotive'){ + if (frm.doc.publish_module == 'Automotive') { let regex = /[!@#$%^*_+\=\[\]{};'`~\\|.<>\?]+/; if (regex.test(frm.doc.release_description) === true) { frm.doc.release_description = ''; frm.refresh_fields(); frappe.msgprint(__("Publish Description: Only letters, numbers and / - () & , ' : are allowed.")); } - + if (frm.doc.vehicle && frm.doc.release_description && frm.fields_dict.publish_documents.grid.grid_rows.length === 0) { frappe.msgprint(__("No item selected to Publish")); frappe.validated = false; @@ -415,9 +360,9 @@ 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')){ + if (frm.doc.publish_module == 'Others' && !frm.doc.hasOwnProperty('repair_checksheet_publish')) { frappe.throw('No Data Found To Publish') - + } }, @@ -459,7 +404,7 @@ frappe.ui.form.on('Publish Test', { }, km_active_status: function (frm) { - if (frm.doc.variant_mapping && frm.doc.publish_module=='Automotive') { + if (frm.doc.variant_mapping && frm.doc.publish_module == 'Automotive') { frappe.show_alert({ message: __('Please wait until variant mapping details are loaded.'), indicator: 'yellow' @@ -467,7 +412,7 @@ frappe.ui.form.on('Publish Test', { } if (frm.doc.km_active_status === "" || frm.doc.km_active_status === null) { return; } let filter = frm.doc.variant_mapping + "-" + frm.doc.language + "-SM"; - if (frm.doc.variant_mapping_status == "Active" && frm.doc.km_active_status == "Active" && frm.doc.publish_module=='Automotive') { + if (frm.doc.variant_mapping_status == "Active" && frm.doc.km_active_status == "Active" && frm.doc.publish_module == 'Automotive') { frappe.call({ "method": "smart_service.transactions.doctype.publish.publish.get_system", "args": { @@ -540,7 +485,7 @@ frappe.ui.form.on('Publish Test', { }) } else { - if (frm.doc.variant_mapping_status && frm.doc.publish_module=='Automotive') { + if (frm.doc.variant_mapping_status && frm.doc.publish_module == 'Automotive') { frappe.msgprint({ title: __('Notification'), indicator: 'red', @@ -551,7 +496,7 @@ frappe.ui.form.on('Publish Test', { }, add_variant_mapping_to_publish: function (frm) { let dulicate = false; - if (frm.doc.publish_documents && frm.doc.publish_module=='Automotive') { + if (frm.doc.publish_documents && frm.doc.publish_module == 'Automotive') { frm.doc.publish_documents.forEach(publishrow => { if (frm.doc.variant_mapping == publishrow.variant_mapping && publishrow.systems === undefined && publishrow.sub_systems === undefined && publishrow.procedure === undefined) { dulicate = true; @@ -559,7 +504,7 @@ frappe.ui.form.on('Publish Test', { }); frappe.msgprint("Variant Mapping already added"); } - if (dulicate === false && frm.doc.publish_module=='Automotive') { + if (dulicate === false && frm.doc.publish_module == 'Automotive') { let child = cur_frm.add_child("publish_documents"); child.variant_mapping = frm.doc.variant_mapping; child.item_category = "Variant Mapping"; @@ -570,8 +515,8 @@ 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) + after_save: function (frm) { + frm.set_df_property('repair_checksheet_publish', 'hidden', 0) frm.refresh_field('repair_checksheet_publish') }, @@ -596,29 +541,29 @@ frappe.ui.form.on('Publish Test', { } }); - if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && frm.doc.publish_module=='Automotive') { return; } + if (frm.doc.vehicle === undefined || frm.doc.vehicle === null && frm.doc.publish_module == 'Automotive') { return; } $("[data-fieldname=variant_mapping]").focus(); if (frm.doc.vehicle) { frm.set_df_property('vehicle', 'read_only', 1); } //other modules-Repair Checksheet - if(frm.doc.publish_module=='Others'){ + if (frm.doc.publish_module == 'Others') { if (frm.doc.repair_checksheet_publish && frm.doc.repair_checksheet_publish.length > 0) { content_flag = 1 cur_frm.clear_table("repair_checksheet_publish"); cur_frm.refresh_fields('repair_checksheet_publish'); - + } add_to_publish(frm) - - - + + + } - + }, language: function (frm) { - if(frm.doc.publish_module=='Others'){ - add_to_publish(frm) + if (frm.doc.publish_module == 'Others') { + add_to_publish(frm) } if (!lang_set_first_time) { frappe.confirm('This will clear all the data, are you sure you want to proceed?', @@ -633,7 +578,7 @@ frappe.ui.form.on('Publish Test', { }, () => { // action to perform if No is selected }); - + } else { lang_set_first_time = false; } }, auto_version_update: function (frm) { @@ -669,13 +614,13 @@ frappe.ui.form.on('Publish_Temp Doc', { }, }) -function add_to_publish(frm){ +function add_to_publish(frm) { frappe.call({ method: "smart_service.phase_2.doctype.publish_test.publish_test.get_service_repair", args: { vehicle: frm.doc.vehicle, language_label: frm.doc.language, publish_type: frm.doc.publish_type }, callback: function (r) { if (r.message) { - cur_frm.set_df_property('repair_checksheet_publish','hidden',0) + cur_frm.set_df_property('repair_checksheet_publish', 'hidden', 0) var records = r.message debugger records.map(v => { @@ -691,7 +636,7 @@ function add_to_publish(frm){ childTable.my_id = v['my_id']; childTable.lang_myid = v['lang_myid']; }) - + cur_frm.refresh_fields("repair_checksheet_publish"); } } diff --git a/smart_service/phase_2/doctype/publish_test/publish_test.json b/smart_service/phase_2/doctype/publish_test/publish_test.json index a7eef47..d839eb1 100644 --- a/smart_service/phase_2/doctype/publish_test/publish_test.json +++ b/smart_service/phase_2/doctype/publish_test/publish_test.json @@ -1,4 +1,5 @@ { + "_liked_by": "[\"Administrator\"]", "actions": [], "autoname": "format: {vehicle}-{language} -{creation}", "creation": "2023-08-07 16:21:22.055887", @@ -141,6 +142,7 @@ "read_only": 1 }, { + "depends_on": "eval:doc.publish_module", "fieldname": "section_break_7", "fieldtype": "Section Break", "label": "Vehicle Details" @@ -327,7 +329,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-08-10 12:12:01.149289", + "modified": "2023-08-11 12:19:11.733139", "modified_by": "Administrator", "module": "Phase-2", "name": "Publish Test", diff --git a/smart_service/phase_2/doctype/publish_test/publish_test.py b/smart_service/phase_2/doctype/publish_test/publish_test.py index 7bd04dc..b28863d 100644 --- a/smart_service/phase_2/doctype/publish_test/publish_test.py +++ b/smart_service/phase_2/doctype/publish_test/publish_test.py @@ -15,11 +15,12 @@ sys.tracebacklimit = 0 site_name = cstr(frappe.local.site) base_url = os.path.expanduser( - "~") + "/frappe-bench/sites/" + site_name + "/public"+"/json_files"+"/Other_Module" + "~") + "/frappe-bench/sites/" + site_name + "/public" + "/files" + "/json_files" + "/Other_Module" frappe.utils.logger.set_log_level("DEBUG") -success_reponse={"status":1,"data":"","message":""} -failure_reponse={"status":0,"data":"","error":""} +success_reponse = {"status": 1, "data": "", "message": ""} +failure_reponse = {"status": 0, "data": "", "error": ""} + class PublishTest(Document): def validate(self): @@ -45,19 +46,21 @@ class PublishTest(Document): for km_mapping in km_mapping_record: self.kilometer_mapping_details = self.kilometer_mapping_details + \ 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': - 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': + 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, 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': # 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_published_docs(self) - 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)) - - def onload1(self): current_db_name = frappe.conf.get("db_name") # To validate updated procedure status @@ -165,12 +168,16 @@ def update_procedure(vehicle, lang, publish_type, doc): frappe.throw("There is no item for global publish") # Generate Publish versions + + def update_publish_status(self): try: - update_status=frappe.db.sql("""update `tabPublish Test` set publish_status="Published" where name='{0}' """.format(self.name)) + update_status = frappe.db.sql( + """update `tabPublish Test` set publish_status="Published" where name='{0}' """.format(self.name)) except Exception as e: return e + @frappe.whitelist() def cal_ver(vehicle, lang, publish_type, doc): update_procedure(vehicle, lang, publish_type, doc) @@ -209,7 +216,7 @@ def global_publish(doc): procedure_link is not null; """.format(current_db_name, doc.name)) asset = frappe.db.sql("""select parent,name from {0}.`tabPublish_Docs` where parent = "{1}" and variant_mapping is not null and procedure_link is null""".format(current_db_name, doc.name)) - + if not procedure and not asset: frappe.throw("There is no item for global publish") @@ -247,6 +254,8 @@ def global_publish(doc): doc.global_publish = publish_record.name doc.save() frappe.msgprint('Global Publish Created for ' + publish_record.name) + + @frappe.whitelist() def generate_global_publish(name): try: @@ -255,26 +264,28 @@ def generate_global_publish(name): "doctype": "Publish Test", "vehicle": res.vehicle, "publish_type": "Global", - "language":res.language, - "release_description":res.release_description, - "publish_module":res.publish_module, - "repair_checksheet_publish":res.repair_checksheet_publish + "language": res.language, + "release_description": res.release_description, + "publish_module": res.publish_module, + "repair_checksheet_publish": res.repair_checksheet_publish }) ret.insert() return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()} except Exception as e: frappe.throw(str(e)) + + @frappe.whitelist() def old_publish(vehicle, language): current_db_name = frappe.conf.get("db_name") publish_record = frappe.db.sql("""select name,publish_type from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}" and publish_status='To Publish' and publish_type = 'Internal' and docstatus != '2'""".format( - current_db_name, vehicle, language), as_dict=1) + current_db_name, vehicle, language), as_dict=1) if publish_record: return publish_record global_publish_record = frappe.db.sql("""select name,publish_type from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}" and publish_status='To Publish' and publish_type = 'Global' and docstatus != '2'""".format( - current_db_name, vehicle, language), as_dict=1) + current_db_name, vehicle, language), as_dict=1) if global_publish_record: return global_publish_record @@ -321,29 +332,29 @@ def update_mapping(variant_mapping, doc): @frappe.whitelist() -def get_vm_asset(doc,lang): +def get_vm_asset(doc, lang): doc = frappe.get_doc("Variant Mapping", doc) vm_assets = frappe.db.sql("""select category,language,attach_file,active_status from {0}.`tabVariant Mapping_Assets` - where parent = "{1}" and language '{2}' and published = '0'; """.format(current_db_name, doc.name,lang), as_dict=1) + where parent = "{1}" and language '{2}' and published = '0'; """.format(current_db_name, doc.name, lang), as_dict=1) return vm_assets @frappe.whitelist() -def get_sm_asset(doc, name,lang): +def get_sm_asset(doc, name, lang): system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = '{3}'; """.format( - current_db_name, doc, name,lang), as_dict=1) + current_db_name, doc, name, lang), as_dict=1) if system_map: for s in system_map: doc = frappe.get_doc("System Mapping", s.name) system_asset = frappe.db.sql("""select systems,language,active_status,system_asset from {0}.`tabSystem Mapping_System Assets` - where parent = "{1}" and language = "{2}" and published = '0'; """.format(current_db_name, s.name,lang), as_dict=1) + where parent = "{1}" and language = "{2}" and published = '0'; """.format(current_db_name, s.name, lang), as_dict=1) return system_asset @frappe.whitelist() -def get_system(doc, name,lang): +def get_system(doc, name, lang): system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping="{1}" and name = "{2}" and language = "{3}";""".format( - current_db_name, doc, name,lang), as_dict=1) + current_db_name, doc, name, lang), as_dict=1) if system_map: for s in system_map: doc = frappe.get_doc("System Mapping", s.name) @@ -352,6 +363,7 @@ def get_system(doc, name,lang): procedure_is_published = "0";""".format(current_db_name, s.name), as_dict=1) return system + @frappe.whitelist() def max_publish(doc): doc = frappe.get_doc("Publish", doc) @@ -435,59 +447,82 @@ def get_service_repair(vehicle, language_label, publish_type): return data -def repair_checksheet_publish(vehicle,vehicle_id,language,publish_type,release_description,variant,parent): +def repair_checksheet_publish(vehicle, vehicle_id, + language, publish_type, release_description, + variant, parent): 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.info(f'Repair Checksheet Started-{vehicle}-{language}-{publish_type}-{parent}') + 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}') '''Publish Ready Flags''' - publish_repair_checksheet=0 + publish_repair_checksheet = 0 + repair_checksheet_tmp = [] '''Create Folder For Publish''' create_publish_folders(folder_url) - file_path = folder_url + "/" + publish_type + "/" + vehicle.replace(' ', - '-')+'-repair_check_sheet' +'.json' - # try: + file_path = folder_url + "/" + publish_type + "/" + \ + vehicle.replace(' ', '-') + '-repair_check_sheet' + '.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': 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: + 'data': '' + } + + '''update existing global json file''' + if os.path.isfile(file_path): + with open(file_path) as f: + published_data = json.load(f) + 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']) > 0: + # Compare with existing + global_publish['data']['repair_checksheet'].append( + repair_checksheet['data'][0]) + repair_checksheet_tmp = published_data['data']['repair_checksheet'] + frappe.msgprint('file_exists' + str(published_data)) + + else: + frappe.msgprint(str('new file')) + 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} + vehicle_data['data'] = 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)) - # frappe.throw('Failed To Publish') + outfile.write(json.dumps(vehicle_data, indent=4, default=str)) - # return e + return 1, file_path - 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)) frappe.throw('Failed To Publish') - + + def update_published_docs(self): try: if self.repair_checksheet_publish: @@ -500,10 +535,10 @@ def update_published_docs(self): except Exception as e: frappe.throw(str(e)) - except: frappe.throw(str(e)) + def create_publish_folders(folder_url): try: @@ -517,31 +552,79 @@ def create_publish_folders(folder_url): except Exception as e: frappe.throw(str(e)) return False + + '''New Module Publish Section''' -def repair_checksheet_data(vehicle=None,language=None,publish_type=None,parent=None): + + +def get_key_value_data(data): + module_dic = {} + for d in data['data']: + module_dic.update({d['name']: d}) + return module_dic + + +def get_latest_data(prev_data, latest_data): + data_dic1 = get_key_value_data(prev_data) + data_dic2 = get_key_value_data(latest_data) + + final_dic = data_dic1.copy() + + for d1 in data_dic1: + if data_dic1[d1]['active_status'] == 'Inactive': + final_dic.pop(d1) + + for d2 in data_dic2: + if data_dic2[d2]['active_status'] == 'Inactive': + final_dic.pop(d2) + else: + final_dic.update({d2: data_dic2[d2]}) + + final_list = list(final_dic.values()) + return final_list + + +def repair_checksheet_data(vehicle=None, language=None, + publish_type=None, parent=None): try: - logger_file=f'{vehicle}-{language}-{publish_type}' - 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 name='{parent}'""", as_dict=1) + logger_file = f'{vehicle} - {language} - {publish_type}' + 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 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) - - logger.info(f"end of fetching repair checksheet data {vehicle}-{language}") - success_reponse['data']=repair_service_details - success_reponse['message']=f'Repair Checksheet Fecthed Succesfully for {vehicle}-{language}' + 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) + + logger.info( + f"end of fetching repair checksheet data {vehicle} - {language}") + success_reponse['data'] = repair_service_details + success_reponse[ + 'message'] = f'Repair Checksheet Fecthed Succesfully for {vehicle} - {language}' return success_reponse - + except Exception as e: - failure_reponse['error']=f"{vehicle}-{language} has following error-" +str(e) - logger.error('error in repair checksheet'+str(e)) + failure_reponse['error'] = f"{vehicle} - {language} has following error - " + str( + e) + logger.error('error in repair checksheet' + str(e)) return failure_reponse -def feature_finder_data(vehicle=None,language=None,publish_type=None,parent=None): +def feature_finder_data(vehicle=None, language=None, + publish_type=None, parent=None): try: pass except Exception as e: - pass \ No newline at end of file + pass diff --git a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js index 23cdfdb..077f12f 100644 --- a/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js +++ b/smart_service/phase_2/doctype/repair_service_mapping/repair_service_mapping.js @@ -47,17 +47,23 @@ frappe.ui.form.on('Repair Service Mapping', { } } }); - } - + } }, - after_save: function (frm) { cur_frm.refresh_fields("display_order") }, - + vehicle:function(frm){ + set_display_order(frm) + } }); function set_display_order(frm){ + if(!frm.doc.vehicle){ + frm.toggle_display('display_order', false) + } + if(frm.doc.vehicle){ + frm.toggle_display('display_order', true) + } if (frm.is_new()) { frm.set_df_property('display_order', 'read_only', 1); } else { diff --git a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js index 4b3ecfe..992f104 100644 --- a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js +++ b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.js @@ -54,19 +54,18 @@ frappe.ui.form.on('Repair Service Master', { if (frm.doc.repairservicename.length > 1) { if (frm.doc.repairservicename.length > 140) { frappe.throw(__("Repair/ServiceName: Only 140 characters are allowed")) - frappe.validate=false; + frappe.validated=false; } else { if (alphanum.test(frm.doc.repairservicename) === true) { - frappe.validated = false; } else if (frm.doc.repairservicename) { frappe.throw(__("Repair/ServiceName: Enter letter or alpha numeric characters only.")); - frappe.validate=false; + frappe.validated=false; } } } else { frappe.throw(__("Repair/ServiceName: Single character not allowed")) - frappe.validate=true; + frappe.validated=false; } } } diff --git a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json index 1349fc2..0f835f3 100644 --- a/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json +++ b/smart_service/phase_2/doctype/repair_service_master/repair_service_master.json @@ -46,12 +46,13 @@ { "fieldname": "display_order", "fieldtype": "Int", + "hidden": 1, "label": "Display Order" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-07 15:55:31.517282", + "modified": "2023-08-14 17:47:39.860103", "modified_by": "Administrator", "module": "Phase-2", "name": "Repair Service Master", diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js index 94109d0..7d3eae7 100644 --- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js +++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.js @@ -25,6 +25,8 @@ frappe.ui.form.on('Special Tool Information', { filters: { display_order: frm.doc.display_order, name: ["!=", frm.doc.name], + vehicle: frm.doc.vehicle, + } }).then(records => { if (records.length) { @@ -50,31 +52,28 @@ frappe.ui.form.on('Special Tool Information', { after_save: function (frm) { cur_frm.refresh_fields("display_order") frm.reload_doc() - - } + }, }); function set_display_order(frm){ - if (frm.is_new()) { - frm.set_df_property('display_order', 'read_only', 1); - } else { - frm.set_df_property('display_order', 'read_only', 0); - } - - frappe.db.count('Special Tool Information',{ - filters:{ - "vehicle":frm.doc.vehicle, - } - }) - .then(count => { - vehicle_count = count + 1; - if (frm.is_new()) { - frm.set_value("display_order", vehicle_count); - } else { - original_display_order = frm.doc.display_order; - } - }); - + if (frm.is_new()) { + frm.set_df_property('display_order', 'read_only', 1); + } else { + frm.set_df_property('display_order', 'read_only', 0); + } + frappe.db.count('Special Tool Information',{ + filters: { + "vehicle": frm.doc.variant + } + }) + .then(count => { + vehicle_count = count + 1; + if (frm.is_new()) { + frm.set_value("display_order", vehicle_count); + } else { + original_display_order = frm.doc.display_order; + } + }); } diff --git a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json index b2c8e05..bcd309c 100644 --- a/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json +++ b/smart_service/phase_2/doctype/special_tool_information/special_tool_information.json @@ -3,7 +3,7 @@ "_liked_by": "[]", "actions": [], "allow_rename": 1, - "autoname": "format:{vehicle}-{category}-", + "autoname": "format:{vehicle}-{category}-{sub_category}", "creation": "2023-08-04 13:09:53.363093", "doctype": "DocType", "editable_grid": 1, @@ -23,6 +23,7 @@ "fieldname": "vehicle", "fieldtype": "Link", "in_list_view": 1, + "in_standard_filter": 1, "label": "Vehicle", "options": "Vehicle", "reqd": 1, @@ -32,6 +33,7 @@ "fieldname": "category", "fieldtype": "Select", "in_list_view": 1, + "in_standard_filter": 1, "label": "Category", "options": "New Tool\nCarry Over", "set_only_once": 1 @@ -76,7 +78,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-10 12:21:54.577165", + "modified": "2023-08-10 16:12:57.846488", "modified_by": "Administrator", "module": "Phase-2", "name": "Special Tool Information", diff --git a/smart_service/phase_2/doctype/training_information_master/training_information_master.js b/smart_service/phase_2/doctype/training_information_master/training_information_master.js index c829949..3f16299 100644 --- a/smart_service/phase_2/doctype/training_information_master/training_information_master.js +++ b/smart_service/phase_2/doctype/training_information_master/training_information_master.js @@ -19,7 +19,6 @@ function check_field_character(field_name) { frappe.validated = false; } else { if (alphanum.test(field_name) === true) { - frappe.validated = true; } else if (field_name) { frappe.throw(__("Training Information Master: Enter letter or alpha numeric characters only.")); frappe.validated = false; diff --git a/smart_service/public/css/smart_service.css b/smart_service/public/css/smart_service.css index 9183ba7..f1edf94 100644 --- a/smart_service/public/css/smart_service.css +++ b/smart_service/public/css/smart_service.css @@ -39,7 +39,7 @@ box-shadow: 7px -2px 11px #E31A37; } .navbar-home img { - max-height: 50px !important; + max-height: 32px !important; width: auto; }
No Content Active StatusFeature TypePost Vin CutOff Name @@ -309,7 +317,7 @@ function custom_tab_html(frm) { spec_custom_dt += '' + val.specification + '' spec_custom_dt += '' + val.value + '' spec_custom_dt += '' + val.active_status + '' - spec_custom_dt += '' + val.feature_type + '' + // spec_custom_dt += '' + val.feature_type + '' if (val.post_vin_cutoff_name) { spec_custom_dt += '' + val.post_vin_cutoff_name + '' } @@ -336,7 +344,7 @@ function custom_tab_html(frm) { image_custom_dt += '' + image_count + '' image_custom_dt += '' + val.image + '' + val.active_status + '' + val.feature_type + '' + val.feature_type + '' + val.post_vin_cutoff_name + '' + content_count + '' + val.content + '' + val.active_status + '' + val.feature_type + '' + val.feature_type + '' + val.post_vin_cutoff_name + '
Edit