Browse Source

MST n instruictions

version2
venkata akhil 12 months ago
parent
commit
a956342305
  1. 126
      smart_service/phase_2/doctype/instructions/instructions.json
  2. 49
      smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json
  3. 22
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.js
  4. 67
      smart_service/phase_2/doctype/special_tool_information/special_tool_information.py

126
smart_service/phase_2/doctype/instructions/instructions.json

@ -1,64 +1,64 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2023-09-21 17:56:22.177272",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"step_name",
"content_type",
"title",
"content",
"attach_file"
],
"fields": [
{
"fieldname": "step_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Step Name"
},
{
"fieldname": "content_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Content Type",
"options": "Heading\nDescription\nCaution\nWarning\nNotice\nImage\nVideo\nPDF",
"read_only_depends_on": "// eval:doc.content_type == 'PDF'",
"set_only_once": 1
},
{
"fieldname": "content",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Content",
"read_only_depends_on": "// eval:doc.content_type=='Image'"
},
{
"depends_on": "// eval:doc.content_type == 'Image'",
"fieldname": "attach_file",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Attach File",
"read_only_depends_on": "// eval:doc.content_type =='Heading';"
},
{
"fieldname": "title",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Title"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-05 17:29:43.636314",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Instructions",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}
"actions": [],
"allow_rename": 1,
"creation": "2023-09-21 17:56:22.177272",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"step_name",
"content_type",
"title",
"content",
"attach_file"
],
"fields": [
{
"fieldname": "step_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Step Name"
},
{
"fieldname": "content_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Content Type",
"options": "Heading\nDescription\nCaution\nWarning\nNotice\nImage\nVideo\nPDF",
"read_only_depends_on": "// eval:doc.content_type == 'PDF'",
"set_only_once": 1
},
{
"fieldname": "content",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Content",
"read_only_depends_on": "// eval:doc.content_type=='Image'"
},
{
"depends_on": "// eval:doc.content_type == 'Image'",
"fieldname": "attach_file",
"fieldtype": "Attach",
"in_list_view": 1,
"label": "Attach File",
"read_only_depends_on": "// eval:doc.content_type =='Heading';"
},
{
"fieldname": "title",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Title"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-10-05 17:29:43.636314",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Instructions",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}

49
smart_service/phase_2/doctype/module_publish_mapping/module_publish_mapping.json

@ -1,6 +1,4 @@
{
"_comments": "[]",
"_liked_by": "[]",
"actions": [],
"allow_rename": 1,
"autoname": "format:{vehicle}-{variant}-{language}-{publish_type}",
@ -34,83 +32,97 @@
{
"fieldname": "vehicle",
"fieldtype": "Data",
"label": "Vehicle"
"label": "Vehicle",
"set_only_once": 1
},
{
"fieldname": "variant",
"fieldtype": "Data",
"label": "Variant"
"label": "Variant",
"set_only_once": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Language"
"label": "Language",
"set_only_once": 1
},
{
"default": "0",
"fieldname": "automotive_system",
"fieldtype": "Check",
"label": "Automotive System"
"label": "Automotive System",
"read_only": 1
},
{
"default": "0",
"fieldname": "tsb",
"fieldtype": "Check",
"label": "TSB"
"label": "TSB",
"read_only": 1
},
{
"default": "0",
"fieldname": "fsa",
"fieldtype": "Check",
"label": "FSA"
"label": "FSA",
"read_only": 1
},
{
"default": "0",
"fieldname": "tekalert",
"fieldtype": "Check",
"label": "TEKalert"
"label": "TEKalert",
"read_only": 1
},
{
"default": "0",
"fieldname": "feature_finder",
"fieldtype": "Check",
"label": "Feature Finder"
"label": "Feature Finder",
"read_only": 1
},
{
"default": "0",
"fieldname": "repairservice_check_sheet",
"fieldtype": "Check",
"label": "Repair/Service Check Sheet"
"label": "Repair/Service Check Sheet",
"read_only": 1
},
{
"default": "0",
"fieldname": "mahindra_special_tool_information",
"fieldtype": "Check",
"label": "Mahindra Special Tool Information"
"label": "Mahindra Special Tool Information",
"read_only": 1
},
{
"default": "0",
"fieldname": "training_information",
"fieldtype": "Check",
"label": "Training Information"
"label": "Training Information",
"read_only": 1
},
{
"default": "0",
"fieldname": "qwik_service",
"fieldtype": "Check",
"label": "QWIK Service"
"label": "QWIK Service",
"read_only": 1
},
{
"default": "0",
"fieldname": "pdi_inspection",
"fieldtype": "Check",
"label": "PDI Inspection"
"label": "PDI Inspection",
"read_only": 1
},
{
"default": "0",
"fieldname": "torque_information_nm",
"fieldtype": "Check",
"label": "Torque Information NM"
"label": "Torque Information NM",
"read_only": 1
},
{
"fieldname": "publish_type",
@ -118,7 +130,8 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Publish Type",
"options": "\nInternal\nGlobal"
"options": "\nInternal\nGlobal",
"set_only_once": 1
},
{
"fieldname": "column_break_2y76a",
@ -143,7 +156,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-04 17:40:33.938964",
"modified": "2023-10-06 12:18:41.170342",
"modified_by": "Administrator",
"module": "Phase-2",
"name": "Module Publish Mapping",

22
smart_service/phase_2/doctype/special_tool_information/special_tool_information.js

@ -66,7 +66,7 @@ frappe.ui.form.on('Special Tool Information', {
});
}
frm.doc.name = frm.doc.vehicle + "-" + frm.doc.tool_type + "-" + frm.doc.category + "-" + frm.doc.aggregate_name
// field validation
if (frm.doc.image) {
frappe.call({
method: "smart_service.phase_2.doctype.special_tool_information.special_tool_information.file_validation",
@ -137,6 +137,26 @@ frappe.ui.form.on('Special Tool Information', {
}
})
}
if (frm.doc.video){
frappe.call({
method: "smart_service.phase_2.doctype.special_tool_information.special_tool_information.file_validation1",
args: {
video: frm.doc.video,
name:frm.doc.name
},
callback: function (r) {
console.log(r.message, "r.message")
if (r.message && r.message[0] == false) {
if (r.message[1] == 1) {
frappe.validated = false;
frappe.msgprint("Invalid file type")
}
}
}
})
}
},
category: function (frm, cdt, cdn) {

67
smart_service/phase_2/doctype/special_tool_information/special_tool_information.py

@ -4,32 +4,36 @@
import frappe
from frappe.model.document import Document
class SpecialToolInformation(Document):
def validate(self):
# self.name=""
if self.is_new():
count = frappe.db.sql('''select max(my_id) as max_count from `tabSpecial Tool Information`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:
self.my_id = 1
if self.keywords:
self.keywords=self.keywords.strip()
if self.tool_name:
self.tool_name=self.tool_name.strip()
if self.aggregate_name:
self.aggregate_name=self.aggregate_name.strip()
self.name = self.vehicle + '-' + \
self.tool_type + '-' + self.category + '-' + self.aggregate_name
else:
self.name = self.vehicle + '-' + self.tool_type + '-' + self.category
def validate(self):
# self.name=""
if self.is_new():
count = frappe.db.sql(
'''select max(my_id) as max_count from `tabSpecial Tool Information`;''')
if count[0][0] is not None:
self.my_id = count[0][0] + 1
else:
self.my_id = 1
if self.keywords:
self.keywords = self.keywords.strip()
if self.tool_name:
self.tool_name = self.tool_name.strip()
if self.aggregate_name:
self.aggregate_name = self.aggregate_name.strip()
self.name = self.vehicle + '-' + \
self.tool_type + '-' + self.category + '-' + self.aggregate_name
else:
self.name = self.vehicle + '-' + self.tool_type + '-' + self.category
if not self.is_new() and self.published == 1:
self.published = 0
if not self.is_new() and self.published == 1:
self.published = 0
@frappe.whitelist()
def file_validation(image, name, value=None):
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext,checking_image, details_of_image,check_mp4_ext ,get_file_size
from smart_service.apis.utils import check_png_ext, check_img_ext, check_zip_ext, check_pdf_ext, checking_image, details_of_image, check_mp4_ext, get_file_size
if image:
res = check_img_ext(image)
res1 = check_png_ext(image)
@ -53,13 +57,15 @@ def file_validation(image, name, value=None):
else:
return True
else:
val = checking_image(image, 'Special Tool Information', value, name)
val = checking_image(
image, 'Special Tool Information', value, name)
if res == False:
ret = res
else:
ret = res1
return ret, 1
@frappe.whitelist()
def file_validation_child(name, 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
@ -116,8 +122,8 @@ def file_validation_child(name, value=None):
@frappe.whitelist()
def file_validation1(image, name, value=None):
from smart_service.apis.utils import check_png_ext, check_img_ext,check_pdf_ext,details_of_image
def file_validation1(image,video, name, value=None):
from smart_service.apis.utils import check_pdf_ext,details_of_image,check_mp4_ext,get_file_size
if image:
res = check_pdf_ext(image)
if res == True:
@ -135,6 +141,19 @@ def file_validation1(image, name, value=None):
if res == False:
ret = res
return ret, 1
if video:
res1=check_mp4_ext(video)
if res1== True:
video_size_mb = get_file_size(video)
if video_size_mb > 100:
val= delete_file(video)
return (False,2)
else:
val = delete_file(video, 'Special Tool Information',
"video", name)
if res == False:
ret = res1
return ret, 1
def delete_file(file_url, attached_to_doctype, attached_to_field, docname, is_child=None):
image_name = frappe.db.get_list("File", fields={"name"}, filters={"file_url": file_url,

Loading…
Cancel
Save