venkata akhil
10 months ago
34 changed files with 448 additions and 299 deletions
@ -0,0 +1,84 @@ |
|||
// 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; |
|||
|
|||
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) |
|||
}, |
|||
}); |
|||
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; |
|||
} |
|||
}); |
|||
} |
@ -0,0 +1,134 @@ |
|||
{ |
|||
"actions": [], |
|||
"allow_rename": 1, |
|||
"autoname": "format:{variant}-{category}-{sub_category}-{language}", |
|||
"creation": "2023-12-01 10:31:27.784999", |
|||
"doctype": "DocType", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"field_order": [ |
|||
"is_published", |
|||
"section_break_qg2b0", |
|||
"variant", |
|||
"vehicle", |
|||
"language", |
|||
"active_status", |
|||
"column_break_gkwxt", |
|||
"category", |
|||
"sub_category", |
|||
"my_id", |
|||
"display_order", |
|||
"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 |
|||
}, |
|||
{ |
|||
"fieldname": "section_break_cmyhs", |
|||
"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", |
|||
"in_standard_filter": 1, |
|||
"label": "Variant", |
|||
"options": "Variant Mapping", |
|||
"reqd": 1, |
|||
"set_only_once": 1 |
|||
}, |
|||
{ |
|||
"fetch_from": "variant.vehicle", |
|||
"fieldname": "vehicle", |
|||
"fieldtype": "Data", |
|||
"label": "Vehicle" |
|||
}, |
|||
{ |
|||
"fieldname": "language", |
|||
"fieldtype": "Link", |
|||
"in_list_view": 1, |
|||
"in_standard_filter": 1, |
|||
"label": "Language", |
|||
"options": "Custom Languages", |
|||
"set_only_once": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "active_status", |
|||
"fieldtype": "Select", |
|||
"label": "Active Status", |
|||
"options": "Active\nInactive" |
|||
}, |
|||
{ |
|||
"default": "0", |
|||
"fieldname": "is_published", |
|||
"fieldtype": "Check", |
|||
"label": "Published" |
|||
}, |
|||
{ |
|||
"fieldname": "section_break_qg2b0", |
|||
"fieldtype": "Section Break" |
|||
} |
|||
], |
|||
"index_web_pages_for_search": 1, |
|||
"links": [], |
|||
"modified": "2023-12-01 12:59:18.226290", |
|||
"modified_by": "Administrator", |
|||
"module": "Phase-2", |
|||
"name": "Torque Manual", |
|||
"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" |
|||
} |
@ -0,0 +1,43 @@ |
|||
# 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 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 check_exe: |
|||
if self.language != "en": |
|||
for d in check_exe: |
|||
self.display_order = d['display_order'] |
|||
self.active_status = d['active_status'] |
|||
if not check_exe: |
|||
if self.language != "en": |
|||
frappe.throw("First language will be english only") |
|||
count = frappe.db.sql('''select max(my_id) as max_count from `tabTorque Manual`;''') |
|||
if count[0][0] is not None: |
|||
self.my_id = count[0][0] + 1 |
|||
else: |
|||
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"], |
|||
"name": ["!=", self.name]}, |
|||
fields={"name", "language", "display_order", "active_status"}) |
|||
if check_exe: |
|||
for i in check_exe: |
|||
res = frappe.get_doc( |
|||
"Torque Manual", i['name']) |
|||
res.display_order = self.display_order |
|||
res.active_status = self.active_status |
|||
res.save() |
|||
except Exception as e: |
|||
raise e |
@ -1,7 +1,7 @@ |
|||
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Torque Subcategory', { |
|||
frappe.ui.form.on('Torque Manual Category', { |
|||
// refresh: function(frm) {
|
|||
|
|||
// }
|
@ -1,7 +1,7 @@ |
|||
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Torque Category', { |
|||
frappe.ui.form.on('Torque Manual Subcategory', { |
|||
// refresh: function(frm) {
|
|||
|
|||
// }
|
@ -1,68 +0,0 @@ |
|||
{ |
|||
"actions": [], |
|||
"allow_rename": 1, |
|||
"creation": "2023-11-24 17:10:52.598215", |
|||
"doctype": "DocType", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"field_order": [ |
|||
"category", |
|||
"column_break_gkwxt", |
|||
"sub_category", |
|||
"section_break_cmyhs", |
|||
"torque_table" |
|||
], |
|||
"fields": [ |
|||
{ |
|||
"fieldname": "category", |
|||
"fieldtype": "Link", |
|||
"in_list_view": 1, |
|||
"label": "Category", |
|||
"options": "Torque Category" |
|||
}, |
|||
{ |
|||
"fieldname": "sub_category", |
|||
"fieldtype": "Link", |
|||
"in_list_view": 1, |
|||
"label": "Sub Category", |
|||
"options": "Torque Subcategory" |
|||
}, |
|||
{ |
|||
"fieldname": "torque_table", |
|||
"fieldtype": "Table", |
|||
"label": "Torque Table", |
|||
"options": "Torque Details" |
|||
}, |
|||
{ |
|||
"fieldname": "column_break_gkwxt", |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"fieldname": "section_break_cmyhs", |
|||
"fieldtype": "Section Break" |
|||
} |
|||
], |
|||
"index_web_pages_for_search": 1, |
|||
"links": [], |
|||
"modified": "2023-11-24 17:12:07.675053", |
|||
"modified_by": "Administrator", |
|||
"module": "Phase-2", |
|||
"name": "Torque Master", |
|||
"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" |
|||
} |
@ -1,7 +1,7 @@ |
|||
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Torque Master', { |
|||
frappe.ui.form.on('Training Information Category', { |
|||
// refresh: function(frm) {
|
|||
|
|||
// }
|
@ -1,32 +0,0 @@ |
|||
// Copyright (c) 2023, Hard n Soft Technologies Pvt Ltd and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Training Information Master', { |
|||
// refresh: function(frm) {
|
|||
|
|||
// }
|
|||
validate: function (frm) { |
|||
check_field_character(frm.doc.category) |
|||
check_field_character(frm.doc.topic) |
|||
} |
|||
}); |
|||
function check_field_character(field_name) { |
|||
if (field_name) { |
|||
var alphanum = /^[a-zA-Z]+/; |
|||
if (field_name.length > 1) { |
|||
if (field_name.length > 100) { |
|||
frappe.throw("<b>Training Information Master:</b> Only <b> 100 </b> characters are allowed") |
|||
frappe.validated = false; |
|||
} else { |
|||
if (alphanum.test(field_name) === true) { |
|||
} else if (field_name) { |
|||
frappe.throw(__("<b>Training Information Master:</b> Enter letter or alpha numeric characters only.")); |
|||
frappe.validated = false; |
|||
} |
|||
} |
|||
} else { |
|||
frappe.throw("<b>Training Information Master:</b> Single character not allowed") |
|||
frappe.validated = false; |
|||
} |
|||
} |
|||
} |
@ -1,22 +0,0 @@ |
|||
# 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 TrainingInformationMaster(Document): |
|||
def validate(self): |
|||
if self.category: |
|||
self.category = self.category.strip() |
|||
if self.topic: |
|||
self.topic = self.topic.strip() |
|||
|
|||
if self.is_new(): |
|||
count = frappe.db.sql('''select max(my_id) as max_count from `tabTraining Information Master`;''') |
|||
if count[0][0] is not None: |
|||
self.my_id = count[0][0] + 1 |
|||
else: |
|||
self.my_id = 1 |
|||
|
|||
|
|||
|
Loading…
Reference in new issue