Browse Source

Torque and training information

version2
venkata akhil 10 months ago
parent
commit
d34585b286
  1. 0
      smart_service/add_ons/doctype/torque_table_column/__init__.py
  2. 8
      smart_service/add_ons/doctype/torque_table_column/test_torque_table_column.py
  3. 8
      smart_service/add_ons/doctype/torque_table_column/torque_table_column.js
  4. 65
      smart_service/add_ons/doctype/torque_table_column/torque_table_column.json
  5. 8
      smart_service/add_ons/doctype/torque_table_column/torque_table_column.py
  6. 0
      smart_service/add_ons/doctype/torque_table_column_child_table/__init__.py
  7. 8
      smart_service/add_ons/doctype/torque_table_column_child_table/test_torque_table_column_child_table.py
  8. 8
      smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.js
  9. 36
      smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.json
  10. 8
      smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.py
  11. 107
      smart_service/apis/v2/master.py
  12. 5
      smart_service/masters/doctype/app_labels/app_labels.json
  13. 5
      smart_service/masters/doctype/variant/variant.json
  14. 99
      smart_service/phase_2/doctype/torque_manual/torque_manual.js
  15. 101
      smart_service/phase_2/doctype/torque_manual/torque_manual.json
  16. 54
      smart_service/phase_2/doctype/torque_manual/torque_manual.py
  17. 4
      smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.json
  18. 4
      smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json
  19. 2
      smart_service/phase_2/doctype/torque_manual_publish_data/torque_manual_publish_data.json
  20. 2
      smart_service/phase_2/doctype/torque_manual_publish_docs/torque_manual_publish_docs.json
  21. 4
      smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.json
  22. 0
      smart_service/phase_2/doctype/torque_table_column/__init__.py
  23. 8
      smart_service/phase_2/doctype/torque_table_column/test_torque_table_column.py
  24. 18
      smart_service/phase_2/doctype/torque_table_column/torque_table_column.js
  25. 65
      smart_service/phase_2/doctype/torque_table_column/torque_table_column.json
  26. 8
      smart_service/phase_2/doctype/torque_table_column/torque_table_column.py
  27. 0
      smart_service/phase_2/doctype/torque_table_column_child_table/__init__.py
  28. 37
      smart_service/phase_2/doctype/torque_table_column_child_table/torque_table_column_child_table.json
  29. 8
      smart_service/phase_2/doctype/torque_table_column_child_table/torque_table_column_child_table.py
  30. 15
      smart_service/phase_2/doctype/training_information/training_information.json
  31. 25
      smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json
  32. 0
      smart_service/phase_2/doctype/training_information_publish_data/__init__.py
  33. 70
      smart_service/phase_2/doctype/training_information_publish_data/training_information_publish_data.json
  34. 8
      smart_service/phase_2/doctype/training_information_publish_data/training_information_publish_data.py
  35. 0
      smart_service/phase_2/doctype/training_information_publish_docs/__init__.py
  36. 70
      smart_service/phase_2/doctype/training_information_publish_docs/training_information_publish_docs.json
  37. 8
      smart_service/phase_2/doctype/training_information_publish_docs/training_information_publish_docs.py
  38. 257
      smart_service/transactions/doctype/publish/publish.js
  39. 22
      smart_service/transactions/doctype/publish/publish.json
  40. 460
      smart_service/transactions/doctype/publish/publish.py
  41. 5
      smart_service/transactions/doctype/system_mapping/system_mapping.json

0
smart_service/add_ons/doctype/torque_table_column/__init__.py

8
smart_service/add_ons/doctype/torque_table_column/test_torque_table_column.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestTorqueTableColumn(unittest.TestCase):
pass

8
smart_service/add_ons/doctype/torque_table_column/torque_table_column.js

@ -0,0 +1,8 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Table Column', {
// refresh: function(frm) {
// }
});

65
smart_service/add_ons/doctype/torque_table_column/torque_table_column.json

@ -0,0 +1,65 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:40:14.464142",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"variant",
"vehicle",
"section_break_bytf4",
"torque_table_columns"
],
"fields": [
{
"fieldname": "torque_table_columns",
"fieldtype": "Table",
"label": "Torque Table Columns",
"options": "Torque Table Column Child Table"
},
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping",
"reqd": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Vehicle",
"reqd": 1
},
{
"fieldname": "section_break_bytf4",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-08 14:53:30.505533",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "Torque Table Column",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/add_ons/doctype/torque_table_column/torque_table_column.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 TorqueTableColumn(Document):
pass

0
smart_service/add_ons/doctype/torque_table_column_child_table/__init__.py

8
smart_service/add_ons/doctype/torque_table_column_child_table/test_torque_table_column_child_table.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestTorqueTableColumnChildTable(unittest.TestCase):
pass

8
smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.js

@ -0,0 +1,8 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Table Column Child Table', {
// refresh: function(frm) {
// }
});

36
smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.json

@ -0,0 +1,36 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:39:31.936009",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"column_number",
"column_name"
],
"fields": [
{
"fieldname": "column_number",
"fieldtype": "Data",
"label": "Column Number"
},
{
"fieldname": "column_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Column Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-08 14:48:55.346403",
"modified_by": "Administrator",
"module": "Add Ons",
"name": "Torque Table Column Child Table",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/add_ons/doctype/torque_table_column_child_table/torque_table_column_child_table.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 TorqueTableColumnChildTable(Document):
pass

107
smart_service/apis/v2/master.py

@ -6,6 +6,8 @@ from frappe import utils
import json
import html
import os
import shutil
import zipfile
from frappe.utils import cstr
@ -13,6 +15,8 @@ from frappe.utils import cstr
site_name = cstr(frappe.local.site)
BASE_URL = os.path.expanduser(
"~") + "/frappe-bench/sites/" + site_name + "/public"
# base = os.path.expanduser(
# "~") + "/frappe-bench/sites/" + site_name
date_format = "%Y-%m-%d %H:%M:%S.%f"
@ -175,7 +179,7 @@ def get_training_information(vehicle, language):
return False, e
@frappe.whitelist(methods=['POST'])
@frappe.whitelist(methods=['POST'],allow_guest=1)
def new_publish():
req = json.loads(frappe.request.data)
try:
@ -292,7 +296,25 @@ def new_publish():
qp_rhs['content'] = cnverted_data
elif module == 'Training Information':
base_path = BASE_URL + "/" + "training" +"/"+ vehicle
scrom_path = base_path +"/"+ "scrom"
# html_path = base_path +"/"+ "/html"
frappe.log_error(str(base_path))
flag, data = get_training_information(vehicle, language)
for d in data:
if len(d['content']) > 0:
for ch in d['content']:
if ch['topic'] == 'SCROM':
scrom_folder_path = base_path +"/"+ "scrom" + "/" + ch['content'].split("/")[2].split(".")[0]
if not os.path.exists(scrom_folder_path):
os.makedirs(scrom_folder_path)
if ch['content']:
frappe.log_error(str(ch['content']))
with zipfile.ZipFile(BASE_URL+ch['content'], 'r') as zip_ref:
zip_ref.extractall(path=scrom_folder_path)
ch['content'] = scrom_folder_path + ch['content'].split("/")[2].split(".")[0]
# cont=frappe.db.sql('''select content from `tabTraining Information Content Reference` where parent = %s and topic = 'SCROM' '''%(d['name']),as_dict=1)
elif module == 'Mahindra Special Tool Information':
CLEANR_back_slash = re.compile("\"")
@ -313,9 +335,9 @@ def new_publish():
elif module == 'PDI Inspection':
pass
elif module == 'Torque Manual':
flag,data = get_torque_manual(variant,language)
elif module == 'Torque Information':
flag, data = get_torque_information(variant, language)
else:
flag = False
data = 'No Module found'
@ -408,7 +430,10 @@ def new_publish1():
data = data.get(variant)
elif module == 'Training Information':
pass
with open(BASE_PATH + str(vehicle) + '-training_information.json') as outfile:
data = json.load(outfile)
data = data.get('data')
# data = data.get(variant)
elif module == 'Mahindra Special Tool Information':
@ -426,8 +451,8 @@ def new_publish1():
elif module == 'Torque Manual':
with open(BASE_PATH + str(vehicle) + '-torque_manual.json') as outfile:
data = json.load(outfile)
data = data.get('data')
data = data.get(variant)
data = data.get('data')
data = data.get(variant)
else:
data = 'No Module found'
@ -479,33 +504,70 @@ def get_qwik_service(variant, language):
return True, qwik_service_details
except Exception as e:
return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_torque_manual(variant,language):
def get_torque_information(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
torque_information_details = frappe.db.sql('''select name,variant,vehicle,language,active_status,category,sub_category,display_order,my_id,keywords
from `tabTorque Manual` where variant ='%s' && language= '%s';''' % (variant, language), as_dict=1)
for t in torque_information_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_information_details
except Exception as e:
return False , e
return False, e
@frappe.whitelist(methods=["POST"], allow_guest=1)
def get_training_information(vehicle,language):
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)
training_information_details = frappe.db.sql('''select name,vehicle,category,display_order,active_status,my_id,keywords 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)
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)
# def test_html(vehicle):
# base_path = BASE_URL + "/" + "/training" +"/"+ vehicle
# # Folder creation
# scrom_path = base_path +"/"+ "/scrom"
# html_path = base_path +"/"+ "/html"
# try:
# # if not os.path.exists(base_path):
# # os.makedirs(base_path)
# if not os.path.exists(scrom_path):
# os.makedirs(scrom_path)
# if not os.path.exists(html_path):
# os.makedirs(html_path)
# # Create zip file
# # try:
# # if path:
# # ext = path.split()[-1]
# # if ext.lower().endswith('.zip'):
# # shutil.unpack_archive(scrom_path, 'zip', base_path)
# # if path:
# # ext = path.split()[-1]
# # if ext.lower().endswith('.html'):
# # shutil.unpack_archive(html_path, 'html', base_path)
# # except:
# # return False, "Failed to create file"
# except Exception as e:
# return e
# @frappe.whitelist()
# def unzip_package(file_path):
# old_path = BASE_URL + file_path
# new_path = BASE_URL + "/training_information"
# shutil.unpack_archive(old_path, new_path)
@frappe.whitelist(allow_guest=1)
def update_publish_mapping(vehicle, variant, language, module):
@ -564,6 +626,9 @@ def input_validation(req):
return sts
@frappe.whitelist()
def get_published_data():
data = frappe.db.sql("""select vehicle,variant,language,publish_type from `tabPublish` where not in (select vehicle,variant,language,publish_type from

5
smart_service/masters/doctype/app_labels/app_labels.json

@ -42,7 +42,8 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "English Label",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_2",
@ -95,7 +96,7 @@
"index_web_pages_for_search": 1,
"is_tree": 1,
"links": [],
"modified": "2023-10-13 15:05:41.477964",
"modified": "2023-12-06 14:59:55.361789",
"modified_by": "Administrator",
"module": "Masters",
"name": "App Labels",

5
smart_service/masters/doctype/variant/variant.json

@ -27,7 +27,8 @@
"in_standard_filter": 1,
"label": "Vehicle",
"options": "Vehicle",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"allow_in_quick_entry": 1,
@ -101,7 +102,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-08 13:55:34.066566",
"modified": "2023-12-06 14:24:53.008660",
"modified_by": "Administrator",
"module": "Masters",
"name": "Variant",

99
smart_service/phase_2/doctype/torque_manual/torque_manual.js

@ -1,84 +1,35 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
var vehicle_count = 0;
var original_display_order = 0;
var vehicle_count = 0;
frappe.ui.form.on('Torque Manual', {
refresh: function(frm) {
frm.set_query("variant", function() {
return {
"filters": {
"active_status": "Active",
}
};
});
set_display_order(frm)
},
onload:function(frm){
set_display_order(frm)
},
validate:function(frm){
cur_frm.refresh_fields("display_order")
if (frm.doc.display_order && frm.doc.name && !frm.is_new()) {
//***check if there is same display_order
frappe.db.get_list('Torque Manual', {
fields: ['display_order', 'name'],
filters: {
display_order: frm.doc.display_order,
name: ["!=", frm.doc.name],
variant: frm.doc.variant,
language: frm.doc.language
}
}).then(records => {
console.log(records)
if (records.length) {
frappe.db.set_value('Torque Manual', records[0].name, {
display_order: original_display_order
}).then(r => {
// console.log("display",str(r))
let doc = r.message;
frappe.show_alert({
message: __('Swapped display order with: ' + records[0].name),
indicator: 'green'
}, 5);
});
} else {
// if (frm.doc.display_order >= vehicle_count) {
// let display_vehicle_count = vehicle_count - 1;
// msgprint('There are only ' + display_vehicle_count + " " + frm.doc.doctype);
// frappe.validated = false;
// }
}
});
}
},
after_save: function (frm) {
cur_frm.refresh_fields("display_order")
},
vehicle: function(frm){
set_display_order(frm)
},
onload: function (frm) {
set_display_order(frm)
},
});
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('Torque Manual', {
filters: {
"variant": frm.doc.variant,
"language": frm.doc.language
}
}).then(count => {
console.log("counts",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('Torque Manual',{
filters: {
"variant": cur_frm.doc.variant,
"language": frm.doc.language,
"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;
}
});
}

101
smart_service/phase_2/doctype/torque_manual/torque_manual.json

@ -1,8 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{variant}-{category}-{sub_category}-{language}",
"creation": "2023-12-01 10:31:27.784999",
"creation": "2023-12-07 14:52:27.406519",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -18,55 +17,21 @@
"sub_category",
"my_id",
"display_order",
"keywords",
"section_break_cmyhs",
"torque_table"
],
"fields": [
{
"fieldname": "category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"options": "Torque Manual Category",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "column_break_gkwxt",
"fieldtype": "Column Break"
},
{
"fieldname": "sub_category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Sub Category",
"options": "Torque Manual Subcategory",
"reqd": 1,
"set_only_once": 1
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "section_break_cmyhs",
"fieldname": "section_break_qg2b0",
"fieldtype": "Section Break"
},
{
"fieldname": "torque_table",
"fieldtype": "Table",
"label": "Torque Table",
"options": "Torque Manual Details"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order"
},
{
"fieldname": "my_id",
"fieldtype": "Int",
"hidden": 1,
"label": "My ID"
},
{
"fieldname": "variant",
"fieldtype": "Link",
@ -98,19 +63,59 @@
"options": "Active\nInactive"
},
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
"fieldname": "column_break_gkwxt",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_qg2b0",
"fieldname": "category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Category",
"options": "Torque Manual Category",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "sub_category",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Sub Category",
"options": "Torque Manual Subcategory",
"reqd": 1,
"set_only_once": 1
},
{
"fieldname": "my_id",
"fieldtype": "Int",
"hidden": 1,
"label": "My ID"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order"
},
{
"fieldname": "keywords",
"fieldtype": "Small Text",
"label": "Keywords"
},
{
"fieldname": "section_break_cmyhs",
"fieldtype": "Section Break"
},
{
"fieldname": "torque_table",
"fieldtype": "Table",
"label": "Torque Table",
"options": "Torque Manual Details"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-01 12:59:18.226290",
"modified": "2023-12-07 16:54:27.415271",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual",

54
smart_service/phase_2/doctype/torque_manual/torque_manual.py

@ -8,8 +8,8 @@ class TorqueManual(Document):
def validate(self):
try:
if self.is_new():
if self.variant and self.language:
check_exe=frappe.db.sql('''select * from `tabTorque Manual` where variant='%s' and language ='en' and name !='%s'; '''%(self.variant,self.name),as_dict=1)
if self.vehicle and self.language:
check_exe=frappe.db.sql('''select * from `tabTorque Manual` where vehicle='%s' and language ='en' and name !='%s'; '''%(self.vehicle,self.name),as_dict=1)
if check_exe:
if self.language != "en":
for d in check_exe:
@ -25,11 +25,13 @@ class TorqueManual(Document):
self.my_id = 1
except Exception as e:
raise e
def on_update(self):
if self.language == "en":
try:
check_exe = frappe.db.get_list("Torque Manual",
filters={"variant": self.variant, "language": ["!=", "en"],
filters={"vehicle": self.vehicle, "language": ["!=", "en"],
"name": ["!=", self.name]},
fields={"name", "language", "display_order", "active_status"})
if check_exe:
@ -41,3 +43,49 @@ class TorqueManual(Document):
res.save()
except Exception as e:
raise e
# @frappe.whitelist()
# def file_validation_child(name=None, value=None):
# from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, details_of_image, checking_image, check_mp4_ext, get_file_size
# if name:
# child_data = frappe.db.sql(
# """select * from `tabTraining Manual Content Reference` where parent='%s'"""%(name), as_dict=1)
# for d in child_data:
# if d['image_video']:
# res = False
# res1 = False
# res2= False
# if d['content_type'] == "Image":
# res = check_img_ext(d['image_video'])
# res1 = check_png_ext(d['image_video'])
# else:
# res2 = check_mp4_ext(d['image_video'])
# if res == True or res1 == True:
# width, height, size = details_of_image(
# d['image_video'])
# if width > 1280 or height > 720 or size > 1*1024 and d['image_video']:
# val = checking_image(
# d['image_video'], "Training Information", value, name, 1)
# frappe.delete_doc("Training Information Content Reference", d['name'])
# if val == True:
# return False, d['idx']
# else:
# return True
# elif res2 == True:
# video_size_mb = get_file_size(d['image_video'])
# if video_size_mb > 10:
# frappe.delete_doc('Training Information Content Reference', d['name'])
# return (False, d['idx'])
# else:
# if res == False and res1==False:
# ret = res
# else:
# ret = res2
# val = checking_image(
# d['image_video'], 'Training Information', value, name, 1)
# frappe.delete_doc('Training Information Content Reference', d['name'])
# return (ret, d['idx'])

4
smart_service/phase_2/doctype/torque_manual_category/torque_manual_category.json

@ -2,7 +2,7 @@
"actions": [],
"allow_rename": 1,
"autoname": "format:{category}",
"creation": "2023-12-01 10:33:34.472251",
"creation": "2023-12-07 14:53:18.133251",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -18,7 +18,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-01 11:55:06.400326",
"modified": "2023-12-07 14:53:18.133251",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Category",

4
smart_service/phase_2/doctype/torque_manual_details/torque_manual_details.json

@ -1,7 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-01 10:31:58.622549",
"creation": "2023-12-07 14:52:59.613295",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -47,7 +47,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-01 10:31:58.622549",
"modified": "2023-12-09 10:34:51.374165",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Details",

2
smart_service/phase_2/doctype/torque_manual_publish_data/torque_manual_publish_data.json

@ -88,7 +88,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-01 18:20:24.959655",
"modified": "2023-12-07 14:54:34.818091",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Publish Data",

2
smart_service/phase_2/doctype/torque_manual_publish_docs/torque_manual_publish_docs.json

@ -81,7 +81,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-01 18:20:06.958959",
"modified": "2023-12-07 14:54:22.200670",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Publish Docs",

4
smart_service/phase_2/doctype/torque_manual_subcategory/torque_manual_subcategory.json

@ -2,7 +2,7 @@
"actions": [],
"allow_rename": 1,
"autoname": "format:{sub_category}",
"creation": "2023-12-01 10:32:52.875051",
"creation": "2023-12-07 14:53:37.290940",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
@ -18,7 +18,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-01 11:55:42.941736",
"modified": "2023-12-07 14:53:37.290940",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Manual Subcategory",

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

8
smart_service/phase_2/doctype/torque_table_column/test_torque_table_column.py

@ -0,0 +1,8 @@
# Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and Contributors
# See license.txt
# import frappe
import unittest
class TestTorqueTableColumn(unittest.TestCase):
pass

18
smart_service/phase_2/doctype/torque_table_column/torque_table_column.js

@ -0,0 +1,18 @@
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
// For license information, please see license.txt
frappe.ui.form.on('Torque Table Column', {
// refresh: function(frm) {
// }
});
frappe.ui.form.on('Torque Table Column Child Table', {
torque_table_columns_add: function(frm,cdt,cdn) {
var child = locals[cdt][cdn];
// if(!child.column_name){
// frappe.msgprint("should add data")
// console.log("column_name"+child.column_name)
// }
}
});

65
smart_service/phase_2/doctype/torque_table_column/torque_table_column.json

@ -0,0 +1,65 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:40:14.464142",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"variant",
"vehicle",
"section_break_bytf4",
"torque_table_columns"
],
"fields": [
{
"fieldname": "variant",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Variant",
"options": "Variant Mapping",
"reqd": 1
},
{
"fetch_from": "variant.vehicle",
"fieldname": "vehicle",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Vehicle",
"reqd": 1
},
{
"fieldname": "section_break_bytf4",
"fieldtype": "Section Break"
},
{
"fieldname": "torque_table_columns",
"fieldtype": "Table",
"label": "Torque Table Columns",
"options": "Torque Table Column Child Table"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-08 15:09:13.185244",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Table Column",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/torque_table_column/torque_table_column.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 TorqueTableColumn(Document):
pass

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

37
smart_service/phase_2/doctype/torque_table_column_child_table/torque_table_column_child_table.json

@ -0,0 +1,37 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-08 14:39:31.936009",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"column_name",
"column_number"
],
"fields": [
{
"fieldname": "column_number",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Column Number"
},
{
"fieldname": "column_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Column Name"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-08 15:41:50.141820",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Torque Table Column Child Table",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/torque_table_column_child_table/torque_table_column_child_table.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 TorqueTableColumnChildTable(Document):
pass

15
smart_service/phase_2/doctype/training_information/training_information.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{category}-{topic}-{language}",
"autoname": "format:{vehicle}-{category}-{language}",
"creation": "2023-08-04 13:35:17.855020",
"doctype": "DocType",
"editable_grid": 1,
@ -15,6 +14,7 @@
"column_break_tweld",
"language",
"active_status",
"keywords",
"section_break_6ucxv",
"content",
"section_break_6kjyf",
@ -32,10 +32,10 @@
},
{
"fieldname": "category",
"fieldtype": "Link",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Category",
"options": "Training Information Category",
"options": "Virtual Assistance\nWebex Training Info",
"set_only_once": 1
},
{
@ -95,11 +95,16 @@
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "keywords",
"fieldtype": "Small Text",
"label": "Keywords"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-01 14:20:25.382259",
"modified": "2023-12-06 17:14:08.241667",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information",

25
smart_service/phase_2/doctype/training_information_content_reference/training_information_content_reference.json

@ -7,7 +7,10 @@
"engine": "InnoDB",
"field_order": [
"topic",
"content"
"content",
"base_path",
"file_name",
"file_url"
],
"fields": [
{
@ -21,12 +24,30 @@
"in_standard_filter": 1,
"label": "Topic",
"options": "Heading\nPDF\nPPT\nSCROM\nVideo\nImage\nAnimation\nWeb Links\nHTML"
},
{
"fieldname": "base_path",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Base Path"
},
{
"fieldname": "file_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "File Name"
},
{
"fieldname": "file_url",
"fieldtype": "Data",
"in_list_view": 1,
"label": "File Url"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-01 13:16:18.488344",
"modified": "2023-12-08 17:19:25.723894",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Content Reference",

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

70
smart_service/phase_2/doctype/training_information_publish_data/training_information_publish_data.json

@ -0,0 +1,70 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-06 15:32:19.529776",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"vehicle",
"language",
"display_order",
"active_status",
"parent1",
"category"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "vehicle",
"fieldtype": "Link",
"label": "Vehicle",
"options": "Vehicle"
},
{
"fieldname": "language",
"fieldtype": "Link",
"label": "Language",
"options": "Custom Languages"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"label": "Parent",
"options": "Training Information"
},
{
"fieldname": "category",
"fieldtype": "Data",
"label": "Category"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-06 17:13:00.364943",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Publish Data",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/training_information_publish_data/training_information_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 TrainingInformationPublishData(Document):
pass

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

70
smart_service/phase_2/doctype/training_information_publish_docs/training_information_publish_docs.json

@ -0,0 +1,70 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-12-06 15:33:08.912681",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"is_published",
"vehicle",
"language",
"display_order",
"active_status",
"parent1",
"category"
],
"fields": [
{
"default": "0",
"fieldname": "is_published",
"fieldtype": "Check",
"label": "Published"
},
{
"fieldname": "vehicle",
"fieldtype": "Link",
"label": "Vehicle",
"options": "Vehicle"
},
{
"fieldname": "language",
"fieldtype": "Link",
"label": "Language",
"options": "Custom Languages"
},
{
"fieldname": "display_order",
"fieldtype": "Int",
"label": "Display Order"
},
{
"fieldname": "active_status",
"fieldtype": "Select",
"label": "Active Status",
"options": "Active\nInactive"
},
{
"fieldname": "parent1",
"fieldtype": "Link",
"label": "Parent",
"options": "Training Information"
},
{
"fieldname": "category",
"fieldtype": "Data",
"label": "Category"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-12-06 17:12:44.104970",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Training Information Publish Docs",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

8
smart_service/phase_2/doctype/training_information_publish_docs/training_information_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 TrainingInformationPublishDocs(Document):
pass

257
smart_service/transactions/doctype/publish/publish.js

@ -80,6 +80,14 @@ frappe.ui.form.on("Publish", {
frm.refresh_field("repiar_checksheet_publish_docs");
cur_frm.set_df_property("repiar_checksheet_publish_docs", "read_only", 1);
}
if (
frm.doc.hasOwnProperty("training_information_publish_docs") &&
frm.doc.training_information_publish_docs.length > 0
) {
frm.set_df_property("training_information_publish_docs", "hidden", 0);
frm.refresh_field("training_information_publish_docs");
cur_frm.set_df_property("training_information_publish_docs", "read_only", 1);
}
if (
frm.doc.hasOwnProperty("feature_finder_publish_docs") &&
frm.doc.feature_finder_publish_docs.length > 0 && frm.doc.docstatus == 1
@ -128,7 +136,6 @@ frappe.ui.form.on("Publish", {
// 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);
@ -154,6 +161,23 @@ frappe.ui.form.on("Publish", {
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Training Information") {
cur_frm.set_df_property("training_information_publish_docs", "read_only", 1);
cur_frm.refresh_field("training_information_publish_docs");
cur_frm.set_df_property("training_information_publish_docs", "hidden", 1);
cur_frm.remove_custom_button("Add To Publish");
if (frm.doc.repiar_checksheet_publish_docs.length > 0) {
frm.set_df_property("training_information_publish_docs", "hidden", 0);
frm.refresh_field("training_information_publish_docs");
cur_frm.set_df_property(
"training_information_publish_docs",
"read_only",
1
);
}
// cur_frm.set_df_property('repiar_checksheet_publish_docs','hidden',0)
// cur_frm.refresh_field('repiar_checksheet_publish_docs')
}
if (frm.doc.docstatus == 1 && frm.doc.publish_module == "Qwik Service") {
// cur_frm.set_df_property("kilometer_mapping_details", "hidden", 1);
cur_frm.set_df_property("qwik_service_publish_docs", "read_only", 1);
@ -205,13 +229,9 @@ frappe.ui.form.on("Publish", {
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.set_df_property("torque_manual_publish_docs", "hidden", 0);
cur_frm.refresh_field("torque_manual_publish_docs");
}
if (
@ -226,6 +246,18 @@ frappe.ui.form.on("Publish", {
cur_frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 0);
cur_frm.refresh_field("repiar_checksheet_publish_docs");
}
if (
(frm.doc.docstatus != 1 && frm.doc.publish_module == "Training Information") ||
frm.doc.publish_type == "Internal" ||
frm.doc.publish_type == "Global"
) {
cur_frm.refresh_field("training_information_publish_docs");
// cur_frm.refresh_field("kilometer_mapping_details");
cur_frm.remove_custom_button("Add To Publish");
cur_frm.set_df_property("training_information_publish_docs", "hidden", 0);
cur_frm.refresh_field("training_information_publish_docs");
}
if (
(frm.doc.docstatus != 1 &&
frm.doc.publish_module == "Qwik Service" &&
@ -334,8 +366,8 @@ frappe.ui.form.on("Publish", {
},
callback: function (r) {
if (r.message == frm.doc.version) {
frm
.add_custom_button(__("Global Publish"), function () {
frm.add_custom_button(__("Global Publish"), function () {
frappe.confirm("Are you sure you want to Publish?", () => {
frappe.call({
method:
@ -491,8 +523,7 @@ frappe.ui.form.on("Publish", {
) {
console.log("call")
frm
.add_custom_button(__("Publish"), function () {
frm.add_custom_button(__("Publish"), function () {
frappe.confirm(
"Are you sure you want to Publish?",
() => {
@ -718,7 +749,7 @@ frappe.ui.form.on("Publish", {
cur_frm.refresh_field("version");
frm.set_value("actual_published_date", frappe.datetime.nowdate());
// window.location.reload();
cur_frm.reload_doc()
// cur_frm.reload_doc()
}
else{
frappe.msgprint("Failed To Publish")
@ -762,7 +793,9 @@ frappe.ui.form.on("Publish", {
!frm.doc.hasOwnProperty("repair_checksheet_publish") &&
!frm.doc.hasOwnProperty("feature_finder_publish") &&
!frm.doc.hasOwnProperty("qwik_service_publish") &&
!frm.doc.hasOwnProperty("special_tool_publish")
!frm.doc.hasOwnProperty("special_tool_publish") &&
!frm.doc.hasOwnProperty("torque_information_publish") &&
!frm.doc.hasOwnProperty("training_information_publish")
) {
frappe.throw("No Data Found To Publish");
}
@ -890,6 +923,9 @@ frappe.ui.form.on("Publish", {
if(frm.doc.publish_module == "Qwik Service"){
add_qwik_service(frm)
}
if(frm.doc.publish_module == "Training Information"){
add_training_information(frm)
}
if (frm.doc.docstatus === 0 && frm.doc.publish_status == 'To Publish' && frm.doc.publish_module=='Feature Finder') {
frm.get_field('feature_finder_publish').grid.add_custom_button(__('Add to Publish'), function () {
@ -961,7 +997,7 @@ frappe.ui.form.on("Publish", {
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);
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;");
@ -970,7 +1006,7 @@ frappe.ui.form.on("Publish", {
else{
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
cur_frm.refresh_field("torque_manual_publish_docs",'read_only',1);
// cur_frm.refresh_field("torque_manual_publish_docs",'read_only',1);
}
});
if (added) { frappe.msgprint(__(added + " Doc(s) Added"));
@ -1177,23 +1213,6 @@ frappe.ui.form.on("Publish", {
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.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.category= row.category;
child.sub_category= row.sub_category;
child.variant = row.variant;
child.active_status = row.active_status;
refresh_field("torque_manual_publish_docs");
frappe.msgprint(__(frm.doc.variant_mapping + " Added"));
}
else{
frappe.msgprint(__(row.parent1 + 'Alraeady Added'))
}
},
km_report: function (frm, cdt, cdn) {
if (frm.doc.publish_module == "Automotive System") {
@ -1205,6 +1224,8 @@ frappe.ui.form.on("Publish", {
after_save: function (frm) {
frm.set_df_property("repair_checksheet_publish", "hidden", 0);
frm.refresh_field("repair_checksheet_publish");
frm.set_df_property("training_information_publish", "hidden", 0);
frm.refresh_field("training_information_publish");
},
vehicle: function (frm) {
@ -1249,6 +1270,9 @@ frappe.ui.form.on("Publish", {
if (frm.doc.publish_module == "Special Tool") {
add_special_tool(frm);
}
if (frm.doc.publish_module == "Training Information") {
add_training_information(frm);
}
if (
frm.doc.vehicle === undefined ||
(frm.doc.vehicle === null &&
@ -1271,10 +1295,20 @@ frappe.ui.form.on("Publish", {
cur_frm.refresh_fields("repair_checksheet_publish");
}
}
if (frm.doc.publish_module == "Training Information") {
if (
frm.doc.training_information_publish &&
frm.doc.training_information_publish.length > 0
) {
content_flag = 1;
cur_frm.clear_table("training_information_publish");
cur_frm.refresh_fields("training_information_publish");
}
}
if (frm.doc.publish_module == "Qwik service") {
if (
frm.doc.repair_checksheet_publish &&
frm.doc.repair_checksheet_publish.length > 0
frm.doc.qwik_service_publish &&
frm.doc.qwik_service_publish.length > 0
) {
content_flag = 1;
cur_frm.clear_table("qwik_service_publish");
@ -1299,10 +1333,14 @@ frappe.ui.form.on("Publish", {
frm.set_value("feature_finder_publish", "");
frm.set_value("qwik_service_publish","");
frm.set_value("torque_manual_publish","");
frm.set_value("training_information_publish","");
frm.set_value("special_tool_publish","");
frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("feature_finder_publish_docs", "");
frm.set_value("qwik_service_publish_docs", "");
frm.set_value("torque_manual_publish_docs", "");
frm.set_value("special_tool_publish_docs", "");
frm.set_value("training_information_publish_docs", "");
if (frm.doc.publish_module == "Repair service" && frm.doc.vehicle) {
@ -1315,6 +1353,16 @@ frappe.ui.form.on("Publish", {
cur_frm.refresh_fields("repair_checksheet_publish");
}
}
if (frm.doc.publish_module == "Training Information" && frm.doc.vehicle) {
add_training_information(frm);
if (
frm.doc.training_information_publish &&
frm.doc.training_information_publish.length > 0
) {
cur_frm.clear_table("training_information_publish");
cur_frm.refresh_fields("training_information_publish");
}
}
if (
frm.doc.publish_module == "Feature Finder" &&
@ -1379,7 +1427,20 @@ frappe.ui.form.on("Publish", {
"This will clear all the data, are you sure you want to proceed?",
() => {
// action to perform if Yes is selected
frm.set_value("feature_finder_publish", null);
frm.set_value("repair_checksheet_publish", null);
lang_set_first_time = false;
},
() => {
// action to perform if No is selected
}
);
}
if (!lang_set_first_time && frm.doc.publish_module == "Training Information") {
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("training_information_publish", null);
lang_set_first_time = false;
},
() => {
@ -1470,16 +1531,21 @@ frappe.ui.form.on("Publish", {
frm.doc.qwik_service_publish="";
frm.doc.special_tool_publish="";
frm.doc.torque_manual_publish="";
frm.doc.training_information_publish="";
frm.set_value("feature_finder_publish_docs", "");
frm.set_value("repiar_checksheet_publish_docs", "");
frm.set_value("qwik_service_publish_docs", "");
frm.set_value("special_tool_publish_docs","");
frm.set_value("torque_manual_publish_docs","");
frm.set_value("training_information_publish","");
frm.set_df_property("repiar_checksheet_publish_docs", "hidden", 1);
frm.refresh_fields();
if (frm.doc.publish_module == "Repair service") {
add_to_publish(frm);
}
if (frm.doc.publish_module == "Training Information") {
add_training_information(frm);
}
if (frm.doc.publish_module == "Automotive System") {
}
@ -1642,6 +1708,129 @@ function add_to_publish(frm) {
});
}
}
function add_training_information(frm) {
cur_frm.clear_table("training_information_publish");
cur_frm.refresh_fields();
document
.getElementsByClassName("btn btn-xs btn-secondary grid-add-row")[4]
.setAttribute("style", "display:none;");
if (frm.doc.vehicle) {
frappe.call({
method:
"smart_service.transactions.doctype.publish.publish.get_training_information",
args: {
vehicle: frm.doc.vehicle,
language_label: frm.doc.language,
publish_type: frm.doc.publish_type,
},
callback: function (r) {
if (r.message.length > 0) {
var records = r.message;
records.map((v) => {
var childTable = cur_frm.add_child("training_information_publish");
childTable.parent1 = v["name"];
childTable.vehicle = v["vehicle"];
childTable.language = v["language"];
childTable.display_order = v["display_order"];
childTable.category = v["category"];
childTable.active_status = v["active_status"];
});
//add to training information published doc table
if (
frm.doc.docstatus === 0 &&
frm.doc.publish_status == "To Publish" &&
frm.doc.publish_module == "Training Information"
) {
frm
.get_field("training_information_publish")
.grid.add_custom_button(__("Add to Publish"), function () {
let added = 0;
frm.doc.training_information_publish.forEach((row) => {
if (
row.active_status == "Active" ||
row.active_status == "Inactive"
) {
let dulicate = false;
if (frm.doc.training_information_publish_docs) {
frm.doc.training_information_publish_docs.forEach(
(publishrow) => {
if (row.parent_name == publishrow.parent_name) {
dulicate = true;
}
}
);
}
if (dulicate === false) {
let child = cur_frm.add_child("training_information_publish_docs");
child.vehicle = frm.doc.vehicle;
child.parent1 = row.parent1;
child.language = row.language;
child.category = row.category;
child.active_status = row.active_status;
refresh_field("training_information_publish_docs");
added += 1;
frm.set_df_property(
"training_information_publish_docs",
"hidden",
0
);
refresh_field("training_information_publish_docs");
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.parent_name + "Alraeady Added"));
}
}
});
if (added) {
frappe.msgprint(__(added + " Doc(s) Added"));
cur_frm.set_df_property(
"training_information_publish",
"read_only",
1
);
cur_frm.refresh_field("training_information_publish");
} else if (added == 0) {
frappe.msgprint(__("No Doc Added"));
}
});
frm.fields_dict.training_information_publish.grid.grid_buttons
.find(".btn-custom")
.removeClass("btn-default")
.addClass("btn-primary");
}
cur_frm.set_df_property("training_information_publish", "hidden", 0);
cur_frm.refresh_field("training_information_publish");
cur_frm.set_df_property(
"training_information_publish_docs",
"read_only",
1
);
cur_frm.refresh_field(
"training_information_publish_docs",
"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;");
}
},
});
}
}
function add_feature_finder(frm) {
cur_frm.clear_table("feature_finder_publish");
cur_frm.refresh_fields();

22
smart_service/transactions/doctype/publish/publish.json

@ -55,7 +55,9 @@
"special_tool_publish",
"special_tool_publish_docs",
"torque_manual_publish",
"torque_manual_publish_docs"
"torque_manual_publish_docs",
"training_information_publish",
"training_information_publish_docs"
],
"fields": [
{
@ -330,7 +332,7 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Module",
"options": "Automotive System\nFeature Finder\nRepair service\nQwik Service\nSpecial Tool\nTorque Manual",
"options": "Automotive System\nFeature Finder\nRepair service\nQwik Service\nSpecial Tool\nTorque Manual\nTraining Information",
"reqd": 1
},
{
@ -419,12 +421,26 @@
"fieldtype": "Table",
"label": "Torque Manual Publish Docs",
"options": "Torque Manual Publish Docs"
},
{
"depends_on": "eval:doc.publish_module =='Training Information';",
"fieldname": "training_information_publish",
"fieldtype": "Table",
"label": "Training Information Publish",
"options": "Training Information Publish Data"
},
{
"depends_on": "eval:doc.publish_module =='Training Information';",
"fieldname": "training_information_publish_docs",
"fieldtype": "Table",
"label": "Training Information Publish Docs",
"options": "Training Information Publish Docs"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2023-12-01 17:39:07.089216",
"modified": "2023-12-06 15:38:46.908708",
"modified_by": "Administrator",
"module": "Transactions",
"name": "Publish",

460
smart_service/transactions/doctype/publish/publish.py

@ -136,7 +136,7 @@ class Publish(Document):
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':
if self.docstatus == 1 and self.publish_module == 'Torque Manual' 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,
@ -144,6 +144,23 @@ class Publish(Document):
update_torque_manual_published_docs(self)
update_publish_status = frappe.db.sql(
"""update `tabPublish` set publish_status='Published' where name='{0}'""".format(self.name))
# training information
if self.docstatus == 1 and self.publish_status == 'To Publish' and self.publish_module == 'Training Information' and self.publish_type == 'Internal':
training_information_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description,self.variant,
self.training_information_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 == 'Training Information' and self.publish_type == 'Global' and self.training_information_publish_docs:
training_information_publish(self.vehicle, self.vehicle_id,
self.language, self.publish_type,
self.release_description,self.variant,
self.training_information_publish_docs)
update_training_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')
update_publish_mapping(self.vehicle, self.variant_mapping,
@ -257,6 +274,21 @@ def update_publish_mapping(vehicle, variant, language, module, publish_type):
f"""UPDATE `tabModule Publish Mapping` set repairservice_check_sheet='1',publish_type='{publish_type}' where name ='{d['name']}'""")
frappe.db.commit()
elif module == 'Training Information':
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
"vehicle": vehicle,
"language": language,
"publish_type": publish_type
}, fields=['name'])
if len(pub_data) > 0:
for d in pub_data:
if d['name']:
frappe.db.sql(
f"""UPDATE `tabModule Publish Mapping` set training_information='1',publish_type='{publish_type}' where name ='{d['name']}'""")
frappe.db.commit()
elif module == 'Special Tool':
pub_data = frappe.db.get_list('Module Publish Mapping', filters={
@ -461,7 +493,18 @@ def generate_global_publish(name, module_name):
"publish_module": res.publish_module,
"torque_manual_publish_docs": res.torque_manual_publish_docs
})
ret.save()
elif module_name == 'Training Information':
ret = frappe.get_doc({
"doctype": "Publish",
"vehicle": res.vehicle,
"publish_type": "Global",
"language": res.language,
"publish_status": 'To Publish',
"release_description": res.release_description,
"publish_module": res.publish_module,
"training_information_publish_docs": res.training_information_publish_docs
})
ret.save()
return {"status": "success", "message": ret.name, "url": frappe.utils.get_url()}
except Exception as e:
frappe.throw(str(e))
@ -662,6 +705,15 @@ def update_special_tool_publish_docs(self):
except Exception as e:
frappe.throw(str(e))
def update_training_published_docs(self):
try:
for d in self.training_information_publish:
frappe.db.sql(
"""UPDATE `tabTraining Information` set published=1 where name='{0}'""".format(d.parent1))
frappe.db.commit()
except Exception as e:
frappe.throw(str(e))
def create_publish_folders(folder_url):
try:
@ -684,17 +736,6 @@ def create_publish_folders(folder_url):
'''New Module Publish Section'''
@frappe.whitelist()
def get_service_repair(vehicle,
language_label, publish_type):
data = frappe.db.sql(f'''
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0;
''', as_dict=1)
return data
def create_df(data_set):
feature_finder_tmp = json.dumps(data_set)
df = pd.DataFrame(json.loads(feature_finder_tmp))
@ -708,17 +749,6 @@ def create_df(data_set):
res1[key] = value.to_dict('records')
return res1
@frappe.whitelist()
def get_feature_finder(vehicle=None, variant=None, language_label=None):
try:
data = frappe.db.sql(
f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and variant_id='{variant}' and language='{language_label}' and is_published=0""", as_dict=1)
return data
except Exception as e:
return str(e)
def repair_checksheet_publish(vehicle, vehicle_id,
language, publish_type, release_description,
variant, parent):
@ -1351,7 +1381,7 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
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)
vehi_data, new_variant_name, torque_manual_tmp)
elif os.path.isfile(file_path) and publish_type == 'Global':
frappe.log_error('inside')
@ -1368,7 +1398,7 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
publish_type, i.parent1, i.variant)
if torque_manual['status'] == 1:
publish_torque_manual = 1
feature_finder_tmp.append(
torque_manual_tmp.append(
torque_manual['data'][0])
torque_manual_tmp = create_df(torque_manual_tmp)
latest_pub_data['data'] = torque_manual_tmp
@ -1463,6 +1493,309 @@ def torque_manual_publish(vehicle=None, vehicle_id=None,
f'{vehicle} - {language} - {publish_type} - {module_name} error in json creation' + str(e))
frappe.throw('Failed To Publish')
# def training_information_publish(vehicle=None, vehicle_id=None,
# language=None, publish_type=None,
# release_description=None,variant=None,parent=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 Training Information 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_training_information = 0
# training_information_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(' ', '-') + '-training_information' + '.json'
# global_file_path = folder_url + "/" + 'Global' + "/" + \
# vehicle.replace(' ', '-') + '-training_information' + '.json'
# full_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-training_information_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(' ', '-') + '-training_information_full_update' + '.json'
# '''Append Published Data to Json'''
# logger.info(
# f'Training 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:
# training_information = training_information_data(vehicle, language,
# publish_type, i.parent1)
# if training_information['status'] == 1:
# publish_training_information = 1
# training_information_tmp.append(
# training_information['data'][0])
# training_information_tmp = create_df(training_information_tmp)
# latest_pub_data['data'] = training_information_tmp
# vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
# 'data': training_information_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,training_information_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(' ', '-') + '-training_information_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:
# training_information = training_information_data(vehicle, language,
# publish_type, i.parent1)
# if training_information['status'] == 1:
# publish_training_information = 1
# training_information_tmp.append(
# training_information['data'][0])
# # training_information_tmp = create_df(training_information_tmp)
# latest_pub_data['data'] = training_information_tmp
# vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
# 'data': training_information_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, training_information_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(' ', '-') + '-training_information_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))
# training_information = training_information_data(
# vehicle, language, publish_type, i.parent1)
# if training_information['status'] == 1:
# publish_training_information = 1
# if len(training_information['data']):
# training_information_tmp.append(
# training_information['data'][0])
# else:
# frappe.throw('failed to publish')
# # training_information_tmp = create_df(training_information_tmp)
# latest_pub_data['data'] = training_information_tmp
# vehi_data = compare_get_data({'data': latest_pub_data['data']}, {
# 'data': training_information_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,training_information_tmp)
# vehicle_data['data'] = vehi_data
# #First Time Global Or Internal
# else:
# for i in parent:
# training_information = training_information_data(
# vehicle, language, publish_type, i.parent1)
# if training_information['status'] == 1:
# publish_training_information = 1
# if len(training_information['data'])>0:
# training_information_tmp.append(
# training_information['data'][0])
# else:
# frappe.throw('failed to publish')
# training_information_tmp = get_latest_data(
# {'data': training_information_tmp}, {'data': []})
# frappe.log_error(str(training_information_tmp))
# # vehi_data = create_df(training_information_tmp)
# latest_pub_data['data'] = training_information_tmp
# 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(' ', '-') + '-training_information_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'] = training_information_tmp
# 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'Training Information 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 training_information_publish(vehicle, vehicle_id,
language, publish_type, release_description,
variant, parent):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - training information'
logger = frappe.logger(logger_file, allow_site=True, file_count=100)
logger.info(
f'Training Information Started-{vehicle}-{language}-{publish_type}-{parent}')
folder_url = base_url+"/"+vehicle.replace(' ', '-') + "/"+language
logger.info(f'Created Folder-{vehicle}-{language}-{publish_type}')
'''Publish Ready Flags'''
publish_training_information = 0
training_information_tmp = []
training_information_tmp1 = []
'''Create Folder For Publish'''
create_publish_folders(folder_url)
file_path = folder_url + "/" + publish_type + "/" + \
vehicle.replace(' ', '-') + '-training_information' + '.json'
# full_update_folder_url = folder_url + "/" + "{}".format(publish_type)+"_Full_Update"
global_file_path = folder_url + "/" + 'Global' + "/" + \
vehicle.replace(' ', '-') + '-training_information' + '.json'
check_inter_file = folder_url + "/" + 'Internal' + "/" + \
vehicle.replace(' ', '-') + '-training_information' + '.json'
'''Append Published Data to Json'''
logger.info(
f'Training Information 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': ''
}
'''update existing global json file'''
if os.path.isfile(global_file_path) and publish_type == 'Internal':
if os.path.isfile(global_file_path):
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
training_information = training_information_data(vehicle, language,
publish_type, i.parent1)
if training_information['status'] == 1:
publish_training_information = 1
training_information_tmp.append(
training_information['data'][0])
training_information_tmp = get_latest_data({'data': published_data['data']}, {
'data': training_information_tmp})
elif os.path.isfile(global_file_path) and publish_type == 'Global':
with open(global_file_path) as f:
published_data = json.load(f)
for i in parent:
training_information = training_information_data(vehicle, language,
publish_type, i.parent1)
if training_information['status'] == 1:
publish_training_information = 1
training_information_tmp.append(
training_information['data'][0])
training_information_tmp = get_latest_data({'data': published_data['data']}, {
'data': training_information_tmp})
if os.path.isfile(check_inter_file):
frappe.log_error(str('internal aleady exists'))
with open(check_inter_file) as f:
published_data = json.load(f)
for i in parent:
training_information = training_information_data(vehicle, language,
publish_type, i.parent1)
if training_information['status'] == 1:
publish_training_information = 1
training_information_tmp1.append(
training_information['data'][0])
frappe.log_error('before' + str(training_information_tmp1))
training_information_tmp = get_latest_data({'data': published_data['data']}, {
'data': training_information_tmp1})
else:
frappe.log_error(str('new internal publish'))
for i in parent:
training_information = training_information_data(
vehicle, language, publish_type, i.parent1)
if training_information['status'] == 1:
publish_training_information = 1
if len(training_information['data']):
training_information_tmp.append(
training_information['data'][0])
# frappe.msgprint(str(repair_checksheet['data'][0]))
training_information_tmp = get_latest_data(
{'data': training_information_tmp}, {'data': []})
frappe.log_error('new pub data' +str(training_information_tmp))
if publish_type == "Global":
#Remove Internal File On Global Publish
internal_check = folder_url + "/" + 'Internal' + "/" + \
vehicle.replace(' ', '-') + '-training_information' + '.json'
if os.path.isfile(internal_check):
os.remove(internal_check)
if publish_training_information == 1:
""" Save publish file """
vehicle_data['data'] = training_information_tmp
frappe.log_error(str(file_path))
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')
def get_key_value_data(data):
module_dic = {}
for d in data['data']:
@ -1802,11 +2135,11 @@ def torque_manual_data(vehicle=None, language=None,
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)
torque_manual_details = frappe.db.sql('''select name,variant,vehicle,language,active_status,category,sub_category,display_order,keywords,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)
`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}")
@ -1820,10 +2153,43 @@ def torque_manual_data(vehicle=None, language=None,
e)
logger.error('error in Torque Manual' + str(e))
return failure_reponse
def training_information_data(vehicle=None, language=None,
publish_type=None, parent=None,variant=None):
try:
logger_file = f'{vehicle} - {language} - {publish_type} - training_information_data'
logger = frappe.logger(logger_file,
allow_site=True, file_count=100)
logger.info(
f"start of fetching training information data - {vehicle} - {language} - {publish_type} - {parent}")
training_information_details = frappe.db.sql(f"""select name,vehicle,category,language,display_order,keywords,my_id,active_status from
`tabTraining Information` where vehicle = '{vehicle}'
and language = '{language}'and name='{parent}' """, as_dict=1)
for d in training_information_details:
d['Content'] = frappe.db.sql(f"""select idx as 'display_order',topic,content from `tabTraining Information Content Reference`
where parent = '{d['name']}'
order by display_order ;""", as_dict=1)
logger.info(
f"end of fetching training informataion data {vehicle} - {language}")
success_reponse['data'] = training_information_details
success_reponse['message'] = f'Training Information Fecthed Succesfully for {vehicle} - {language} - training_information_data '
return success_reponse
except Exception as e:
failure_reponse['error'] = f"{vehicle} - {language} has following error - " + str(
e)
logger.error('error in Training Information' + str(e))
return failure_reponse
@frappe.whitelist()
def max_publish_new_module(doc):
doc = frappe.get_doc("Publish", doc)
ver = frappe.db.sql("""select max(version) from {0}.tabPublish where vehicle = "{1}" and language = "{2}" and publish_module!="Automotive System";""".format(
ver = frappe.db.sql("""select max(version) from {0}.`tabPublish` where vehicle = "{1}" and language = "{2}" and publish_module!="Automotive System";""".format(
current_db_name, doc.vehicle, doc.language))
if ver:
@ -1831,7 +2197,7 @@ def max_publish_new_module(doc):
@frappe.whitelist()
def cal_ver_new_module(vehicle, lang, publish_type, doc):
def cal_ver_new_module(vehicle, lang, publish_type, doc=None):
try:
current_db_name = frappe.conf.get("db_name")
doc = frappe.get_doc("Publish", doc)
@ -1859,9 +2225,33 @@ def cal_ver_new_module(vehicle, lang, publish_type, doc):
except Exception as e:
return {"status": 0, "data": "None", "error": str(e)}
@frappe.whitelist()
def get_service_repair(vehicle,
language_label, publish_type):
data = frappe.db.sql(f'''
select * from `tabRepair Service Mapping` where vehicle = '{vehicle}' and language='{language_label}' and published = 0;
''', as_dict=1)
return data
@frappe.whitelist()
def get_qwik_service(variant=None, language_label=None, kilometers=None):
def get_feature_finder(vehicle=None, variant=None, language_label=None):
try:
data = frappe.db.sql(
f"""select * from `tabFeature Finder` where vehicle='{vehicle}' and variant_id='{variant}' and language='{language_label}' and is_published=0""", as_dict=1)
return data
except Exception as e:
return str(e)
@frappe.whitelist()
def get_training_information(vehicle=None,language_label=None):
try:
data = frappe.db.sql('''
select * from `tabTraining Information` where vehicle = '%s' and language='%s' and is_published = '%s';''' % (vehicle,language_label,0), as_dict=1)
return data
except Exception as e:
return str(e)
@frappe.whitelist()
def get_qwik_service(variant=None, language_label=None):
try:
data = frappe.db.sql("""select * from `tabQwik Service` where variant='%s'
and language = '%s' and is_published = '%s';""" % (variant, language_label, 0), as_dict=1)
@ -1872,7 +2262,7 @@ def get_qwik_service(variant=None, language_label=None, kilometers=None):
@frappe.whitelist()
def get_special_tool(vehicle=None, publish_type=None):
def get_special_tool(vehicle=None):
data = frappe.db.sql('''
select * from `tabSpecial Tool Information` where vehicle ='%s' and published = '%s';''' % (vehicle, 0), as_dict=1)
return data
@ -1881,8 +2271,8 @@ def get_special_tool(vehicle=None, publish_type=None):
@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)
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)

5
smart_service/transactions/doctype/system_mapping/system_mapping.json

@ -37,7 +37,8 @@
"in_standard_filter": 1,
"label": "Variant Mapping",
"options": "Variant Mapping",
"reqd": 1
"reqd": 1,
"set_only_once": 1
},
{
"default": "Active",
@ -173,7 +174,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-10 11:02:23.963612",
"modified": "2023-12-06 15:01:55.755864",
"modified_by": "Administrator",
"module": "Transactions",
"name": "System Mapping",

Loading…
Cancel
Save