Browse Source

Torque manual publish

version2
venkata akhil 10 months ago
parent
commit
b205a9b8ba
  1. 2
      smart_service/apis/publish_api.py
  2. 44
      smart_service/apis/v2/master.py
  3. 8
      smart_service/phase_2/doctype/feature_finder/feature_finder.js
  4. 0
      smart_service/phase_2/doctype/torque_manual_publish_data/__init__.py
  5. 99
      smart_service/phase_2/doctype/torque_manual_publish_data/torque_manual_publish_data.json
  6. 8
      smart_service/phase_2/doctype/torque_manual_publish_data/torque_manual_publish_data.py
  7. 0
      smart_service/phase_2/doctype/torque_manual_publish_docs/__init__.py
  8. 92
      smart_service/phase_2/doctype/torque_manual_publish_docs/torque_manual_publish_docs.json
  9. 8
      smart_service/phase_2/doctype/torque_manual_publish_docs/torque_manual_publish_docs.py
  10. 2
      smart_service/phase_2/doctype/training_information/training_information.json
  11. 278
      smart_service/transactions/doctype/publish/publish.js
  12. 24
      smart_service/transactions/doctype/publish/publish.json
  13. 273
      smart_service/transactions/doctype/publish/publish.py

2
smart_service/apis/publish_api.py

@ -488,7 +488,7 @@ def new_publish(args, publish_type, vehicle, language, version):
return True, file_name1.split("public")[1] return True, file_name1.split("public")[1]
else: else:
pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}" pub_ver = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM `tabPublish` where vehicle = "{}"
and publish_type = "Global" AND `language` = "{}" and publish_module="Automotive System" order by modified desc;""".format(vehicle, language), as_dict=1) and publish_type = "Global" AND `language` = "{}" and publish_module="Automotive System" order by modified desc;""".format(vehicle, language), as_dict=1)
if pub_ver: if pub_ver:

44
smart_service/apis/v2/master.py

@ -292,8 +292,7 @@ def new_publish():
qp_rhs['content'] = cnverted_data qp_rhs['content'] = cnverted_data
elif module == 'Training Information': elif module == 'Training Information':
# flag, data = get_training_information(vehicle, language) flag, data = get_training_information(vehicle, language)
pass
elif module == 'Mahindra Special Tool Information': elif module == 'Mahindra Special Tool Information':
CLEANR_back_slash = re.compile("\"") CLEANR_back_slash = re.compile("\"")
@ -314,8 +313,8 @@ def new_publish():
elif module == 'PDI Inspection': elif module == 'PDI Inspection':
pass pass
elif module == 'Torque Information NM': elif module == 'Torque Manual':
pass flag,data = get_torque_manual(variant,language)
else: else:
flag = False flag = False
@ -357,8 +356,8 @@ def new_publish1():
else: else:
return {"status": 0, "error": "Publish Type Not Set For: " + iid} return {"status": 0, "error": "Publish Type Not Set For: " + iid}
# BASE_PATH = BASE_URL + "/files/json_files/phase2/" + \ BASE_PATH = BASE_URL + "/files/json_files/phase2/" + \
# str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/' str(vehicle) + '/' + str(language) + '/' + str(publish_type) + '/'
FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \ FULL_UPDATE_PATH = BASE_URL + "/files/json_files/phase2/" + \
str(vehicle) + '/' + str(language) + '/' + \ str(vehicle) + '/' + str(language) + '/' + \
"{}".format(publish_type)+"_Full_Update/" "{}".format(publish_type)+"_Full_Update/"
@ -424,8 +423,11 @@ def new_publish1():
elif module == 'PDI Inspection': elif module == 'PDI Inspection':
pass pass
elif module == 'Torque Information NM': elif module == 'Torque Manual':
pass with open(BASE_PATH + str(vehicle) + '-torque_manual.json') as outfile:
data = json.load(outfile)
data = data.get('data')
data = data.get(variant)
else: else:
data = 'No Module found' data = 'No Module found'
@ -479,6 +481,32 @@ def get_qwik_service(variant, language):
return False, e return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_torque_manual(variant,language):
try:
torque_manual_details = frappe.db.sql('''select name,variant,vehicle,language,active_status,category,sub_category,display_order,my_id
from `tabTorque Manual` where variant ='%s' && language= '%s';'''%(variant,language), as_dict=1)
for t in torque_manual_details:
t['torque_table']= frappe.db.sql(''' select idx as 'display_order',fastener_description,specification,qty,torque_nm,remark from
`tabTorque Manual Details` where parent = '%s' order by display_order;'''%(t['name']),as_dict=1)
return True,torque_manual_details
except Exception as e:
return False , e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_training_information(vehicle,language):
try:
training_information_details = frappe.db.sql('''select name,vehicle,category,display_order,active_status,my_id from
`tabTraining Information` where vehicle = '%s' && language = '%s';'''%(vehicle,language),as_dict=1)
for i in training_information_details:
i['content'] = frappe.db.sql('''select idx as 'display_order',topic,content from `tabTraining Information Content Reference`
where parent = '%s' order by display_order;'''%(i['name']),as_dict=1)
return True, training_information_details
except Exception as e:
raise e
@frappe.whitelist(allow_guest=1) @frappe.whitelist(allow_guest=1)
def update_publish_mapping(vehicle, variant, language, module): def update_publish_mapping(vehicle, variant, language, module):
frappe.set_user('Administrator') frappe.set_user('Administrator')

8
smart_service/phase_2/doctype/feature_finder/feature_finder.js

@ -1150,6 +1150,13 @@ function custom_tab_html(frm) {
// size: 'small', // small, large, extra-large // size: 'small', // small, large, extra-large
primary_action_label: 'Submit', primary_action_label: 'Submit',
primary_action(values) { primary_action(values) {
//Not allow more than 500 cahracters
var args = spec_dia.get_values();
var content_limit = args.content.length
if(content_limit>500){
frappe.throw("<b>Content:</b> Only <b> 500 </b> characters are allowed")
}
if (values && values.content) { if (values && values.content) {
frappe.call({ frappe.call({
method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_content_data", method: "smart_service.phase_2.doctype.feature_finder.feature_finder.insert_content_data",
@ -1160,6 +1167,7 @@ function custom_tab_html(frm) {
}, },
callback: function (r) { callback: function (r) {
if (r.message.status == "success") { if (r.message.status == "success") {
frappe.show_alert({ frappe.show_alert({
message: __('Submited data will be auto saved'), message: __('Submited data will be auto saved'),
indicator: 'green' indicator: 'green'

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

99
smart_service/phase_2/doctype/torque_manual_publish_data/torque_manual_publish_data.json

@ -0,0 +1,99 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-01 16:25:50.626564",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"variant",
"vehicle",
"language",
"display_order",
"category",
"active_status",
"sub_category",
"parent1"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published",
"read_only": 1
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping",
"read_only": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"read_only": 1
},
{
"fieldname": "language",
"fieldtype": "Link",
"label": "Language",
"options": "Custom Languages"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"in_standard_filter": 1,
"label": "Display Order",
"read_only": 1
},
{
"fieldname": "category",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"read_only": 1
},
{
"fieldname": "sub_category",
"fieldtype": "Data",
"in_global_search": 1,
"in_standard_filter": 1,
"label": "Sub Category",
"read_only": 1
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Parent",
"options": "Torque Manual",
"read_only": 1
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active Status",
"options": "Active\nInactive"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-01 18:20:24.959655",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Publish Data",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/torque_manual_publish_data/torque_manual_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 TorqueManualPublishData(Document):
pass

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

92
smart_service/phase_2/doctype/torque_manual_publish_docs/torque_manual_publish_docs.json

@ -0,0 +1,92 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-01 16:42:33.197929",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"variant",
"vehicle",
"language",
"display_order",
"category",
"sub_category",
"active_status",
"parent1"
],
"fields": [
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping",
"read_only": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Vehicle",
"read_only": 1
},
{
"fieldname": "language",
"fieldtype": "Link",
"label": "Language",
"options": "Custom Languages",
"set_only_once": 1
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"in_standard_filter": 1,
"label": "Display Order",
"read_only": 1
},
{
"fieldname": "category",
"fieldtype": "Data",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"read_only": 1
},
{
"fieldname": "sub_category",
"fieldtype": "Data",
"in_global_search": 1,
"in_standard_filter": 1,
"label": "Sub Category",
"read_only": 1
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Parent",
"options": "Torque Manual",
"read_only": 1
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active status",
"options": "Active\nInactive"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-01 18:20:06.958959",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Publish Docs",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/torque_manual_publish_docs/torque_manual_publish_docs.py

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

2
smart_service/phase_2/doctype/training_information/training_information.json

@ -99,7 +99,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-12-01 13:19:50.127628", "modified": "2023-12-01 14:20:25.382259",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Phase-2", "module": "Phase-2",
"name": "Training Information", "name": "Training Information",

278
smart_service/transactions/doctype/publish/publish.js

@ -88,6 +88,14 @@ frappe.ui.form.on("Publish", {
cur_frm.set_df_property("feature_finder_publish_docs", "read_only", 1); cur_frm.set_df_property("feature_finder_publish_docs", "read_only", 1);
frm.refresh_field("feature_finder_publish_docs"); frm.refresh_field("feature_finder_publish_docs");
} }
if (
frm.doc.hasOwnProperty("torque_manual_publish_docs") &&
frm.doc.feature_finder_publish_docs.length > 0 && frm.doc.docstatus == 1
) {
frm.set_df_property("torque_manual_publish_docs", "hidden", 0);
cur_frm.set_df_property("torque_manual_publish_docs", "read_only", 1);
frm.refresh_field("torque_manual_publish_docs");
}
if ( if (
frm.doc.hasOwnProperty("qwik_service_publish_docs") && frm.doc.hasOwnProperty("qwik_service_publish_docs") &&
frm.doc.qwik_service_publish_docs.length > 0 frm.doc.qwik_service_publish_docs.length > 0
@ -116,6 +124,18 @@ frappe.ui.form.on("Publish", {
cur_frm.set_df_property("feature_finder_publish", "read_only", 1); cur_frm.set_df_property("feature_finder_publish", "read_only", 1);
} }
} }
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Torque Manual") {
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.set_df_property("torque_manual_publish_docs", "read_only", 1);
cur_frm.refresh_field("torque_manual_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.feature_finder_publish.length > 0) {
frm.set_df_property("torque_manual_publish", "hidden", 1);
frm.refresh_field("torque_manual_publish");
cur_frm.set_df_property("torque_manual_publish", "read_only", 1);
}
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Repair service") { if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Repair service") {
cur_frm.set_df_property("repiar_checksheet_publish_docs", "read_only", 1); cur_frm.set_df_property("repiar_checksheet_publish_docs", "read_only", 1);
@ -178,6 +198,22 @@ frappe.ui.form.on("Publish", {
cur_frm.set_df_property("feature_finder_publish_docs", "hidden", 0); cur_frm.set_df_property("feature_finder_publish_docs", "hidden", 0);
cur_frm.refresh_field("feature_finder_publish_docs"); cur_frm.refresh_field("feature_finder_publish_docs");
} }
if (
(frm.doc.docstatus != 1 &&
frm.doc.publish_module == "Torque Manual" &&
frm.doc.torque_manual_publish_docs.length > 0 &&
frm.doc.publish_type == "Internal") ||
frm.doc.publish_type == "Global"
) {
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.refresh_field("torque_manual_publish_docs");
cur_frm.refresh_field("kilometer_mapping_details");
cur_frm.remove_custom_button("Add To Publish");
cur_frm.set_df_property("torque_manual_publish_docs", "hidden", 0);
cur_frm.refresh_field("torque_manual_publish_docs");
}
if ( if (
(frm.doc.docstatus != 1 && frm.doc.publish_module == "Repair service") || (frm.doc.docstatus != 1 && frm.doc.publish_module == "Repair service") ||
frm.doc.publish_type == "Internal" || frm.doc.publish_type == "Internal" ||
@ -848,6 +884,9 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Feature Finder") { if (frm.doc.publish_module == "Feature Finder") {
add_feature_finder(frm); add_feature_finder(frm);
} }
if (frm.doc.publish_module == "Torque Manual") {
add_torque_manual(frm);
}
if(frm.doc.publish_module == "Qwik Service"){ if(frm.doc.publish_module == "Qwik Service"){
add_qwik_service(frm) add_qwik_service(frm)
} }
@ -896,6 +935,53 @@ frappe.ui.form.on("Publish", {
frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary'); frm.fields_dict.repair_checksheet_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
} }
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Torque Manual') {
frm.get_field('torque_manual_publish').grid.add_custom_button(__('Add to Publish'), function () {
let added = 0;
frm.doc.torque_manual_publish.forEach(row => {
if (row.active_status == "Active" || row.active_status == "Inactive") {
let dulicate = false;
if (frm.doc.torque_manual_publish_docs) {
frm.doc.torque_manual_publish_docs.forEach(publishrow => {
if (row.parent1 == publishrow.parent1) {
dulicate = true;
}
});
}
if (dulicate === false) {
let child = cur_frm.add_child("torque_manual_publish_docs");
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
child.category= row.category;
child.sub_category= row.sub_category;
child.active_status = row.active_status;
added += 1;
frm.set_df_property('torque_manual_publish_docs','hidden',0)
cur_frm.refresh_field("torque_manual_publish",'read_only',1);
refresh_field("torque_manual_publish_docs");
cur_frm.set_df_property("torque_manual_publish",'read_only',1);
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[4] .setAttribute("style","display:none;");
document.getElementsByClassName('btn btn-xs btn-secondary grid-add-row')[5] .setAttribute("style","display:none;");
}
else{
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
cur_frm.refresh_field("torque_manual_publish_docs",'read_only',1);
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property('torque_manual_publish','read_only',1)
cur_frm.set_df_property("torque_manual_publish_docs",'read_only',1);
cur_frm.refresh_field("torque_manual_publish"); }
else if(added==0) { frappe.msgprint(__("No Doc Added")); }
});
frm.fields_dict.torque_manual_publish.grid.grid_buttons.find('.btn-custom').removeClass('btn-default').addClass('btn-primary');
}
if (frm.doc.publish_module == "Automotive System") { if (frm.doc.publish_module == "Automotive System") {
let km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM"; let km_name = frm.doc.variant_mapping + "-" + frm.doc.language + "-KM";
frappe.db.get_value( frappe.db.get_value(
@ -1082,15 +1168,26 @@ frappe.ui.form.on("Publish", {
frappe.msgprint("Variant Mapping already added"); frappe.msgprint("Variant Mapping already added");
} }
if (dulicate === false && frm.doc.publish_module == 'Feature Finder') { if(frm.doc.torque_manual_publish_docs && frm.doc.publish_module=='Torque Manual'){
let child = cur_frm.add_child("feature_finder_publish_docs"); frm.doc.publish_documents.forEach(publishrow => {
if (frm.doc.variant_mapping == publishrow.variant_mapping) {
dulicate = true;
}
});
frappe.msgprint("Variant Mapping already added");
}
if (dulicate === false && frm.doc.publish_module == 'Torque Manual') {
let child = cur_frm.add_child("torque_manual_publish_docs");
child.variant_mapping = frm.doc.variant_mapping; child.variant_mapping = frm.doc.variant_mapping;
child.vehicle = frm.doc.vehicle; child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1; child.parent1 = row.parent1;
child.language = row.language; child.language = row.language;
child.category= row.category;
child.sub_category= row.sub_category;
child.variant = row.variant; child.variant = row.variant;
child.active_status = row.active_status; child.active_status = row.active_status;
refresh_field("feature_finder_publish_docs"); refresh_field("torque_manual_publish_docs");
frappe.msgprint(__(frm.doc.variant_mapping + " Added")); frappe.msgprint(__(frm.doc.variant_mapping + " Added"));
} }
else{ else{
@ -1201,9 +1298,11 @@ frappe.ui.form.on("Publish", {
frm.set_value("repair_checksheet_publish", ""); frm.set_value("repair_checksheet_publish", "");
frm.set_value("feature_finder_publish", ""); frm.set_value("feature_finder_publish", "");
frm.set_value("qwik_service_publish",""); frm.set_value("qwik_service_publish","");
frm.set_value("torque_manual_publish","");
frm.set_value("repiar_checksheet_publish_docs", ""); frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("feature_finder_publish_docs", ""); frm.set_value("feature_finder_publish_docs", "");
frm.set_value("qwik_service_publish_docs", ""); frm.set_value("qwik_service_publish_docs", "");
frm.set_value("torque_manual_publish_docs", "");
if (frm.doc.publish_module == "Repair service" && frm.doc.vehicle) { if (frm.doc.publish_module == "Repair service" && frm.doc.vehicle) {
@ -1230,6 +1329,19 @@ frappe.ui.form.on("Publish", {
cur_frm.refresh_fields("feature_finder_publish"); cur_frm.refresh_fields("feature_finder_publish");
} }
} }
if (
frm.doc.publish_module == "Torque Manual" &&
frm.doc.vehicle &&
frm.doc.variant_mapping
) {
if (
frm.doc.torque_manual_publish &&
frm.doc.torque_manual_publish.length > 0
) {
cur_frm.clear_table("torque_manual_publish");
cur_frm.refresh_fields("torque_manual_publish");
}
}
if ( if (
frm.doc.publish_module == "Qwik Service" && frm.doc.publish_module == "Qwik Service" &&
@ -1289,6 +1401,21 @@ frappe.ui.form.on("Publish", {
} }
); );
}
if (!lang_set_first_time && frm.doc.publish_module == "Torque Manual") {
frappe.confirm(
"This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
frm.set_value("torque_manual_publish", null);
frm.set_value("variant_mapping", "");
lang_set_first_time = false;
},
() => {
// action to perform if No is selected
}
);
} }
if (!lang_set_first_time && frm.doc.publish_module == "Qwik Service") { if (!lang_set_first_time && frm.doc.publish_module == "Qwik Service") {
frappe.confirm( frappe.confirm(
@ -1342,10 +1469,12 @@ frappe.ui.form.on("Publish", {
frm.doc.feature_finder_publish = ""; frm.doc.feature_finder_publish = "";
frm.doc.qwik_service_publish=""; frm.doc.qwik_service_publish="";
frm.doc.special_tool_publish=""; frm.doc.special_tool_publish="";
frm.doc.torque_manual_publish="";
frm.set_value("feature_finder_publish_docs", ""); frm.set_value("feature_finder_publish_docs", "");
frm.set_value("repiar_checksheet_publish_docs", ""); frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("qwik_service_publish_docs", ""); frm.set_value("qwik_service_publish_docs", "");
frm.set_value("special_tool_publish_docs",""); frm.set_value("special_tool_publish_docs","");
frm.set_value("torque_manual_publish_docs","");
frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1); frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1);
frm.refresh_fields(); frm.refresh_fields();
if (frm.doc.publish_module == "Repair service") { if (frm.doc.publish_module == "Repair service") {
@ -1357,6 +1486,10 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Feature Finder") { if (frm.doc.publish_module == "Feature Finder") {
add_feature_finder(frm); add_feature_finder(frm);
} }
if (frm.doc.publish_module == "Torque Manual") {
add_torque_manual(frm);
}
if(frm.doc.publish_module == "Qwik Service"){ if(frm.doc.publish_module == "Qwik Service"){
add_qwik_service(frm) add_qwik_service(frm)
} }
@ -1644,6 +1777,145 @@ function add_feature_finder(frm) {
}, },
}); });
} }
function add_torque_manual(frm) {
cur_frm.clear_table("torque_manual_publish");
cur_frm.refresh_fields();
var fin_add_btn = document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[3]
.setAttribute("style", "display:none;");
frappe.call({
method:
"smart_service.transactions.doctype.publish.publish.get_torque_manual",
args: {
vehicle: frm.doc.vehicle,
variant: frm.doc.variant_mapping,
language_label: frm.doc.language,
publish_type: frm.doc.publish_type,
},
callback: function (r) {
if (r.message.length > 0) {
cur_frm.set_df_property("torque_manual_publish", "hidden", 0);
var records = r.message;
records.map((v) => {
var childTable = cur_frm.add_child("torque_manual_publish");
childTable.parent1 = v["name"];
childTable.vehicle = v["vehicle"];
childTable.language = v["language"];
childTable.variant = v["variant"];
childTable.active_status = v["active_status"];
childTable.category = v["category"];
childTable.sub_category = v["sub_category"]
});
//add to repair service published doc table
if (
frm.doc.docstatus === 0 &&
frm.doc.publish_status == "To Publish" &&
frm.doc.publish_module == "Torque Manual"
) {
frm
.get_field("torque_manual_publish")
.grid.add_custom_button(__("Add to Publish"), function () {
let added = 0;
frm.doc.torque_manual_publish.forEach((row) => {
if (
row.active_status == "Active" ||
row.active_status == "Inactive"
) {
let dulicate = false;
if (frm.doc.torque_manual_publish) {
frm.doc.torque_manual_publish_docs.forEach(
(publishrow) => {
if (row.parent1 == publishrow.parent1) {
dulicate = true;
}
}
);
}
if (dulicate === false) {
let child = cur_frm.add_child(
"torque_manual_publish_docs"
);
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.variant = row.variant;
child.category= row.category;
child.sub_category= row.sub_category;
child.active_status = row.active_status;
added += 1;
frm.set_df_property(
"torque_manual_publish_docs",
"hidden",
0
);
cur_frm.refresh_field(
"torque_manual_publish",
"read_only",
1
);
refresh_field("torque_manual_publish_docs");
cur_frm.set_df_property(
"torque_manual_publish",
"read_only",
1
);
document
.getElementsByClassName(
"btn btn-xs btn-secondary grid-add-row"
)[4]
.setAttribute("style", "display:none;");
document
.getElementsByClassName(
"btn btn-xs btn-secondary grid-add-row"
)[5]
.setAttribute("style", "display:none;");
frm.fields_dict.torque_manual_publish.grid.grid_buttons
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
} else {
frappe.msgprint(__(row.parent1 + "Alraeady Added"));
}
cur_frm.refresh_field(
"torque_manual_publish_docs",
"read_only",
1
);
}
});
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property(
"torque_manual_publish",
"read_only",
1
);
cur_frm.set_df_property(
"torque_manual_publish_docs",
"read_only",
1
);
cur_frm.refresh_field("torque_manual_publish");
} else if (added == 0) {
frappe.msgprint(__("No Doc Added"));
}
});
frm.fields_dict.torque_manual_publish.grid.grid_buttons
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
}
cur_frm.set_df_property("torque_manual_publish", "hidden", 0);
cur_frm.refresh_field("torque_manual_publish");
let find_add_btn = document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[3]
.setAttribute("style", "display:none;");
}
},
});
}
function add_qwik_service(frm){ function add_qwik_service(frm){
cur_frm.clear_table("Qwik_service_publish"); cur_frm.clear_table("Qwik_service_publish");
cur_frm.refresh_fields(); cur_frm.refresh_fields();

24
smart_service/transactions/doctype/publish/publish.json

@ -53,7 +53,9 @@
"qwik_service_publish", "qwik_service_publish",
"qwik_service_publish_docs", "qwik_service_publish_docs",
"special_tool_publish", "special_tool_publish",
"special_tool_publish_docs" "special_tool_publish_docs",
"torque_manual_publish",
"torque_manual_publish_docs"
], ],
"fields": [ "fields": [
{ {
@ -108,7 +110,7 @@
"set_only_once": 1 "set_only_once": 1
}, },
{ {
"depends_on": "eval:doc.vehicle && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Feature Finder' || doc.publish_module=='Qwik Service' ", "depends_on": "eval:doc.vehicle && doc.docstatus == 0 && doc.publish_module=='Automotive System' || doc.publish_module=='Feature Finder' || doc.publish_module=='Qwik Service' || doc.publish_module=='Qwik Service' || doc.publish_module=='Torque Manual' ",
"fieldname": "variant_mapping", "fieldname": "variant_mapping",
"fieldtype": "Link", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
@ -328,7 +330,7 @@
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Module", "label": "Module",
"options": "Automotive System\nFeature Finder\nRepair service\nQwik Service\nSpecial Tool", "options": "Automotive System\nFeature Finder\nRepair service\nQwik Service\nSpecial Tool\nTorque Manual",
"reqd": 1 "reqd": 1
}, },
{ {
@ -403,12 +405,26 @@
"fieldname": "variant_mapping_html", "fieldname": "variant_mapping_html",
"fieldtype": "HTML", "fieldtype": "HTML",
"label": "Variant Mapping HTML" "label": "Variant Mapping HTML"
},
{
"depends_on": "eval:doc.publish_module =='Torque Manual';",
"fieldname": "torque_manual_publish",
"fieldtype": "Table",
"label": "Torque Manual Publish",
"options": "Torque Manual Publish Data"
},
{
"depends_on": "eval:doc.publish_module =='Torque Manual';",
"fieldname": "torque_manual_publish_docs",
"fieldtype": "Table",
"label": "Torque Manual Publish Docs",
"options": "Torque Manual Publish Docs"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2023-11-27 12:34:08.109971", "modified": "2023-12-01 17:39:07.089216",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Publish", "name": "Publish",

273
smart_service/transactions/doctype/publish/publish.py

@ -60,14 +60,7 @@ class Publish(Document):
def on_submit(self): def on_submit(self):
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Internal': # qwik_service
repair_res_obj = repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.repiar_checksheet_publish_docs)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Internal': if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Qwik Service' and self.publish_type == 'Internal':
qwik_service_publish(self.vehicle, self.vehicle_id, self.variant, qwik_service_publish(self.vehicle, self.vehicle_id, self.variant,
self.language, self.publish_type, self.language, self.publish_type,
@ -85,6 +78,7 @@ class Publish(Document):
update_qwik_published_docs(self) update_qwik_published_docs(self)
update_publish_status = frappe.db.sql( update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
# feature_finder
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.publish_type == 'Internal' and self.feature_finder_publish_docs: if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Feature Finder' and self.publish_type == 'Internal' and self.feature_finder_publish_docs:
feature_finder_publish(self.vehicle, self.vehicle_id, feature_finder_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type, self.language, self.publish_type,
@ -100,6 +94,15 @@ class Publish(Document):
update_feature_published_docs(self) update_feature_published_docs(self)
update_publish_status = frappe.db.sql( update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
# repair_service
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Internal':
repair_res_obj = repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.variant,
self.repiar_checksheet_publish_docs)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Global' and self.repiar_checksheet_publish_docs: if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Repair service' and self.publish_type == 'Global' and self.repiar_checksheet_publish_docs:
repair_checksheet_publish(self.vehicle, self.vehicle_id, repair_checksheet_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type, self.language, self.publish_type,
@ -108,7 +111,7 @@ class Publish(Document):
update_repair_published_docs(self) update_repair_published_docs(self)
update_publish_status = frappe.db.sql( update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
# special tool
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Internal': if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Special Tool' and self.publish_type == 'Internal':
special_tool_publish(self.vehicle, self.vehicle_id, special_tool_publish(self.vehicle, self.vehicle_id,
self.publish_type, self.publish_type,
@ -125,6 +128,23 @@ class Publish(Document):
update_publish_status = frappe.db.sql( update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name)) """update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
# torque_manual
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Torque Manual' and self.publish_type == 'Internal' and self.torque_manual_publish_docs:
torque_manual_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.torque_manual_publish_docs, self.variant)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
if self.docstatus == 1 and self.publish_module == 'Feature Finder' and self.publish_type == 'Global':
torque_manual_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description, self.torque_manual_publish_docs,
self.variant)
update_torque_manual_published_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
variant = self.variant_mapping_details.split('/n') variant = self.variant_mapping_details.split('/n')
update_publish_mapping(self.vehicle, self.variant_mapping, update_publish_mapping(self.vehicle, self.variant_mapping,
self.language, self.publish_module, self.publish_type) self.language, self.publish_module, self.publish_type)
@ -211,6 +231,14 @@ def update_qwik_published_docs(self):
except Exception as ex: except Exception as ex:
return str(ex) return str(ex)
def update_torque_manual_published_docs(self):
try:
for d in self.torque_manual_publish_docs:
frappe.db.sql(''' update `tabTorque Manual` set is_published=1 where name='{0}';'''.format(d.parent1))
frappe.db.commit()
except Exception as e:
raise e
def update_publish_mapping(vehicle, variant, language, module, publish_type): def update_publish_mapping(vehicle, variant, language, module, publish_type):
# frappe.set_user('Administrator') # frappe.set_user('Administrator')
@ -421,6 +449,18 @@ def generate_global_publish(name, module_name):
"publish_module": res.publish_module "publish_module": res.publish_module
}) })
elif module_name == 'Torque Manual':
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
"variant_mapping_details": res.variant_mapping_details,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
"torque_manual_publish_docs": res.torque_manual_publish_docs
})
ret.save() ret.save()
return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()} return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()}
except Exception as e: except Exception as e:
@ -1243,6 +1283,186 @@ def special_tool_publish(vehicle, vehicle_id,
frappe.throw('Failed To Publish') frappe.throw('Failed To Publish')
def torque_manual_publish(vehicle=None, vehicle_id=None,
language=None, publish_type=None,
release_description=None, parent=None,
variant=None):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - {module_name} - {variant}'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching Torque Manual data - {vehicle} - {language} - {module_name} - {variant}")
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Final Json'''
vehicle_data = {
'vehicle': vehicle,
'vehicle_myid': vehicle_id,
'publish_type': publish_type,
'publish_description': release_description,
'publish_language': language,
'data': ''
}
latest_pub_data = vehicle_data.copy()
'''Publish Ready Flags'''
publish_torque_manual= 0
torque_manual_tmp = []
'''Create Folder For Publish'''
create_publish_folders(folder_url)
full_update_folder_url = folder_url + "/" + "{}".format(publish_type)+"_Full_Update"
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-torque_manual' + '.json'
global_file_path = folder_url + "/" + 'Global' + "/" + \
vehicle.replace(' ', '-') + '-torque_manual' + '.json'
full_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-torque_manual_full_update' + '.json'
# full_internal_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
global_full_update_path = folder_url + "/" + "Global_Full_Update"
check_glbl_full_updte = global_full_update_path+"/" + vehicle.replace(' ', '-') + '-torque_manual_full_update' + '.json'
'''Append Published Data to Json'''
logger.info(
f'Feature Data Append Start::{vehicle}-{language}-{publish_type}')
'''update existing global json file'''
if os.path.isfile(global_file_path) and publish_type == 'Internal':
if os.path.isfile(check_glbl_full_updte):
with open(check_glbl_full_updte) as f:
published_data = json.load(f)
for i in parent:
torque_manual = torque_manual_data(vehicle, language,
publish_type, i.parent1, i.variant)
if torque_manual['status'] == 1:
publish_torque_manual = 1
torque_manual_tmp.append(
torque_manual['data'][0])
torque_manual_tmp = create_df(torque_manual_tmp)
latest_pub_data['data'] = torque_manual_tmp
vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
x for x in new_variant if x not in find_distinct]
vehi_data = add_new_val(
vehi_data, new_variant_name, feature_finder_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
frappe.log_error('inside')
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
#Remove Internal Full Update File On Global Publish
existing_internal_full_update = full_update_folder_url_internal+"/" + vehicle.replace(' ', '-') + '-torque_manual_full_update' + '.json'
frappe.log_error('file_path' + str(existing_internal_full_update))
if os.path.isfile(existing_internal_full_update):
os.remove(existing_internal_full_update)
with open(check_glbl_full_updte) as f:
published_data = json.load(f)
for i in parent:
torque_manual = torque_manual_data(vehicle, language,
publish_type, i.parent1, i.variant)
if torque_manual['status'] == 1:
publish_torque_manual = 1
feature_finder_tmp.append(
torque_manual['data'][0])
torque_manual_tmp = create_df(torque_manual_tmp)
latest_pub_data['data'] = torque_manual_tmp
vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
x for x in new_variant if x not in find_distinct]
vehi_data = add_new_val(
vehi_data, new_variant_name, torque_manual_tmp)
else:
#Existing Global or Internal Full Update
internal_full_update_check = full_update_folder_url = folder_url + "/" +"Internal_Full_Update"
check_full_update_file = internal_full_update_check+"/" + vehicle.replace(' ', '-') + '-torque_manual_full_update' + '.json'
if os.path.isfile(check_full_update_file):
with open(check_full_update_file) as f:
published_data = json.load(f)
for i in parent:
frappe.log_error("i",str(parent))
torque_manual = torque_manual_data(
vehicle, language, publish_type, i.parent1, i.variant)
if torque_manual['status'] == 1:
publish_torque_manual = 1
if len(torque_manual['data']):
torque_manual_tmp.append(
torque_manual['data'][0])
else:
frappe.throw('failed to publish')
torque_manual_tmp = create_df(torque_manual_tmp)
latest_pub_data['data'] = torque_manual_tmp
vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
'data': torque_manual_tmp})
if vehi_data:
find_distinct = set(exisitng_var)
new_variant_name = [
x for x in new_variant if x not in find_distinct]
vehi_data = add_new_val(
vehi_data, new_variant_name, torque_manual_tmp)
vehicle_data['data'] = vehi_data
#First Time Global Or Internal
else:
for i in parent:
frappe.log_error("619",str(parent))
torque_manual = torque_manual_data(
vehicle, language, publish_type, i.parent1, i.variant)
if torque_manual['status'] == 1:
publish_torque_manual = 1
if len(torque_manual['data'])>0:
torque_manual_tmp.append(
torque_manual['data'][0])
else:
frappe.throw('failed to publish')
torque_manual_tmp = get_latest_data(
{'data': torque_manual_tmp}, {'data': []})
frappe.log_error(str(torque_manual_tmp))
vehi_data = create_df(torque_manual_tmp)
latest_pub_data['data'] = vehi_data
if publish_type == "Global":
full_update_folder_url_internal = folder_url + "/" + "Internal_Full_Update"
#Remove Internal Full Update File On Global Publish
existing_internal_full_update = full_update_folder_url_internal+"/" + vehicle.replace(' ', '-') + '-torque_manual_full_update' + '.json'
frappe.log_error('file_path' + str(existing_internal_full_update))
if os.path.isfile(existing_internal_full_update):
os.remove(existing_internal_full_update)
""" Save publish file """
vehicle_data['data'] = vehi_data
with open(file_path, 'w') as outfile:
outfile.write(json.dumps(latest_pub_data, indent=4, default=str))
with open(full_update_file, 'w') as outfile:
outfile.write(json.dumps(vehicle_data, indent=4, default=str))
logger.info(
f'Torque Manual Data Append Start::{vehicle}-{language}-{publish_type}')
return 1, file_path
except Exception as e:
logger.info(
f'{vehicle} - {language} - {publish_type} - {module_name} error in json creation' + str(e))
frappe.throw('Failed To Publish')
def get_key_value_data(data): def get_key_value_data(data):
module_dic = {} module_dic = {}
for d in data['data']: for d in data['data']:
@ -1574,7 +1794,32 @@ def special_tool_data(vehicle=None,
logger.error('error in special tool' + str(e)) logger.error('error in special tool' + str(e))
return failure_reponse return failure_reponse
def torque_manual_data(vehicle=None, language=None,
publish_type=None, parent=None, variant=None):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - {module_name} - {variant} - fetch data'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching torque manual data - {vehicle} - {language} - {variant} - {module_name}")
torque_manual_details = frappe.db.sql('''select name,variant,vehicle,language,active_status,category,sub_category,display_order,my_id
from `tabTorque Manual` where variant ='%s' && language= '%s';'''%(variant,language), as_dict=1)
for t in torque_manual_details:
t['torque_table']= frappe.db.sql(''' select idx as 'display_order',fastener_description,specification,qty,torque_nm,remark from
`tabTorque Manual Details` where parent = '%s' order by display_order;'''%(t['name']),as_dict=1)
logger.info(
f"end of Torque Manual data {variant} - {language}")
success_reponse['data'] = torque_manual_details
success_reponse[
'message'] = f'Torque Manual 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 Torque Manual' + str(e))
return failure_reponse
@frappe.whitelist() @frappe.whitelist()
def max_publish_new_module(doc): def max_publish_new_module(doc):
doc = frappe.get_doc("Publish", doc) doc = frappe.get_doc("Publish", doc)
@ -1631,3 +1876,13 @@ def get_special_tool(vehicle=None, publish_type=None):
data = frappe.db.sql(''' data = frappe.db.sql('''
select * from `tabSpecial Tool Information` where vehicle ='%s' and published = '%s';''' % (vehicle, 0), as_dict=1) select * from `tabSpecial Tool Information` where vehicle ='%s' and published = '%s';''' % (vehicle, 0), as_dict=1)
return data return data
@frappe.whitelist()
def get_torque_manual(variant=None, language_label=None):
try:
data = frappe.db.sql(
"""select * from `tabTorque Manual` where variant='%s' and language='%s' and is_published='%s';"""%(variant,language_label,0), as_dict=1)
return data
except Exception as e:
return str(e)
Loading…
Cancel
Save