Jecintha 1 year ago
parent
commit
e4687410c2
  1. 171
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js
  2. 7
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json
  3. 32
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.py
  4. 5
      smart_service/transactions/doctype/system_mapping/system_mapping.js
  5. 11
      smart_service/transactions/doctype/system_mapping/system_mapping.json

171
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.js

@ -56,66 +56,9 @@ frappe.ui.form.on('Kilometer Mapping', {
}, },
validate: function (frm) { validate: function (frm) {
// //custom button if (frm.doc.__unsaved == 1){
// frm.add_custom_button(__("Duplicate Data"), function () { frm.doc.workflow_state = "Draft";
// let d = new frappe.ui.Dialog({ }
// title: 'Choose the variant',
// fields: [
// {
// label: 'Variant',
// fieldname: 'variant',
// fieldtype: 'Link',
// options: "Kilometer Mapping"
// },
// {
// label: '',
// fieldname: 'content_html',
// fieldtype: 'HTML',
// },
// ],
// size: 'small',
// secondary_action_label: "No",
// primary_action_label: 'Yes',
// primary_action(values) {
// console.log(values);
// if (values) {
// if (frm.doc.config_kilometer && frm.doc.config_kilometer.length > 0) {
// cur_frm.clear_table("config_kilometer");
// cur_frm.refresh_fields('config_kilometer');
// }
// cur_frm.refresh_fields("config_kilometer");
// frappe.call({
// "method": "smart_service.transactions.doctype.kilometer_mapping.kilometer_mapping.get_config_kilometer",
// "args": {
// "doc": values.variant,
// "docname": frm.doc.name
// },
// callback: function (r) {
// if (r.message && r.message.length > 0) {
// cur_frm.refresh_fields("config_kilometer");
// frm.save()
// frm.refresh()
// }
// }
// })
// d.hide();
// }
// },
// secondary_action(values) {
// d.hide();
// }
// });
// d.show();
// var res = $(d.fields_dict.content_html.wrapper).empty();
// var ret = "<p>Upload the Kilometer</p>"
// res.append(ret)
// }).css({ "color": "#fff", "background-color": "red" });;
// //end
frm.doc.kilometer_filter = "All"; frm.doc.kilometer_filter = "All";
if (frm.doc.kilometer_filter == "All") { if (frm.doc.kilometer_filter == "All") {
@ -129,63 +72,61 @@ frappe.ui.form.on('Kilometer Mapping', {
}, },
refresh: function (frm) { refresh: function (frm) {
//custom button //custom duplicate button
// frm.add_custom_button(__("Duplicate Data"), function () { frm.add_custom_button(__("Duplicate Data"), function () {
// let d = new frappe.ui.Dialog({ let d = new frappe.ui.Dialog({
// title: 'Choose the variant', title: 'Choose the variant',
// fields: [ fields: [
// { {
// label: 'Kilometer Mapping', label: 'Kilometer Mapping',
// fieldname: 'variant', fieldname: 'variant',
// fieldtype: 'Link', fieldtype: 'Link',
// options: "Kilometer Mapping", options: "Kilometer Mapping",
// reqd: 1 reqd: 1
// } }
// ], ],
// size: 'small', size: 'small',
// secondary_action_label: "No", secondary_action_label: "No",
// primary_action_label: 'Yes', primary_action_label: 'Yes',
// primary_action(values) { primary_action(values) {
// console.log(values.variant); if (values.variant) {
// if (values.variant) { cur_frm.refresh_fields("config_kilometer");
// console.log("calling") frappe.call({
// cur_frm.refresh_fields("config_kilometer"); "method": "smart_service.transactions.doctype.kilometer_mapping.kilometer_mapping.get_config_kilometer",
// frappe.call({ "args": {
// "method": "smart_service.transactions.doctype.kilometer_mapping.kilometer_mapping.get_config_kilometer", "doc": values.variant,
// "args": { "docname": frm.doc.name
// "doc": values.variant, },
// "docname": frm.doc.name callback: function (r) {
// }, if (r.message && r.message['status'] == "success") {
// callback: function (r) { cur_frm.refresh_fields("config_kilometer");
// if (r.message && r.message.length > 0) { frm.save()
// cur_frm.refresh_fields("config_kilometer");
// frm.save()
// frm.refresh()
// }
// }
// })
// d.hide();
// }
// else {
// d.hide()
// }
// },
// secondary_action(values) {
// d.hide();
// }
// });
// d.show(); frappe.show_alert({
// setTimeout(function mysam() { message: __('Saved'),
// console.log("jiiii", $('.modal-dialog').find('.custom-actions').html('<p>Are you sure to update the kilometer mapping?</p>')) indicator: 'green'
// $('.modal-dialog').find('.custom-actions').html('<p>Are you sure to update the <b>kilometer mapping</b>?</p>') }, 5);
// } cur_frm.reload_doc();
// , 300); }
}
})
d.hide();
}
else {
d.hide()
}
},
secondary_action(values) {
d.hide();
}
});
// // var res = $(d.fields_dict.content_html.wrapper).empty(); d.show();
// // var ret="<p>Are you sure to update the kilometer mapping ?</p>" setTimeout(function mysam() {
// // res.append(ret) $('.modal-dialog').find('.custom-actions').html('<p>Are you sure to update the <b>kilometer mapping</b>?</p>')
// }).css({ "color": "#fff", "background-color": "red" });; }
, 300);
}).css({ "color": "#fff", "background-color": "red" });;
//end //end
if (frm.doc.kilometer_filter == "All") { if (frm.doc.kilometer_filter == "All") {

7
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json

@ -128,12 +128,14 @@
{ {
"fieldname": "sub_system_filter", "fieldname": "sub_system_filter",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 1,
"label": "Sub System", "label": "Sub System",
"read_only_depends_on": "eval:doc.kilometer_filter == \"All\"" "read_only_depends_on": "eval:doc.kilometer_filter == \"All\""
}, },
{ {
"fieldname": "column_break_14", "fieldname": "column_break_14",
"fieldtype": "Column Break" "fieldtype": "Column Break",
"hidden": 1
}, },
{ {
"fieldname": "section_break_16", "fieldname": "section_break_16",
@ -142,6 +144,7 @@
{ {
"fieldname": "kilometer_filter", "fieldname": "kilometer_filter",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 1,
"label": "Kilometer" "label": "Kilometer"
}, },
{ {
@ -175,7 +178,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-11-08 18:59:09.017588", "modified": "2023-11-10 10:47:32.084847",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Kilometer Mapping", "name": "Kilometer Mapping",

32
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.py

@ -4,8 +4,9 @@
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
import sys import sys
from frappe import _
sys.tracebacklimit=0 sys.tracebacklimit=0
current_db_name = frappe.conf.get("db_name")
class KilometerMapping(Document): class KilometerMapping(Document):
def onload(self): def onload(self):
###Kilometer mapping config table idx allignment ###Kilometer mapping config table idx allignment
@ -14,10 +15,9 @@ class KilometerMapping(Document):
for x in self.get("config_kilometer"): for x in self.get("config_kilometer"):
idx += 1 idx += 1
x.idx = idx x.idx = idx
@frappe.whitelist() @frappe.whitelist()
def get_system(doc): def get_system(doc):
current_db_name = frappe.conf.get("db_name")
system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping='{1}'""".format(current_db_name,doc),as_dict=True) system_map = frappe.db.sql("""select name from {0}.`tabSystem Mapping` where variant_mapping='{1}'""".format(current_db_name,doc),as_dict=True)
if system_map: if system_map:
for s in system_map: for s in system_map:
@ -36,6 +36,22 @@ def get_subsystem(doc):
return sub_system return sub_system
@frappe.whitelist()
def update_duplicate_km(doc,kilometer):
km = frappe.get_doc("Kilometer Mapping",doc)
output = frappe.db.sql("""select kilometer,mat,sub_systems,row_name from `tabKilometer Mapping_Items` where parent = '{0}' and kilometer = '{1}' order by kilometer""".format(doc,kilometer),as_dict=True)
# frappe.msgprint(str(output))
for data in output:
# frappe.msgprint(str(data['mat']))
km.append('duplicate_kilometer_mapping_items', {
'kilometer': data['kilometer'],
'mat': data['mat'],
'sub_systems': data['sub_systems'],
'row_name': data['row_name']
})
km.save(ignore_permissions=True)
@frappe.whitelist() @frappe.whitelist()
@ -50,3 +66,13 @@ def get_config_kilometer(doc,docname):
frappe.db.commit() frappe.db.commit()
return {"status":"success"} return {"status":"success"}
# @frappe.whitelist()
# def km_filter(parent = None , record = None, km = None):
# if record == "All":
# km_filters = frappe.db.sql(f"""select * from `tabKilometer Mapping_Items` where parent ="{parent}" order by length(kilometer),kilometer;""",as_dict = 1)
# else:
# km_filters =frappe.db.sql(f"""select * from `tabKilometer Mapping_Items` where parent ="{parent}" and kilometer ="{km}" order by length(kilometer),kilometer """,as_dict = 1)
# return km_filters

5
smart_service/transactions/doctype/system_mapping/system_mapping.js

@ -175,7 +175,7 @@ frappe.ui.form.on('System Mapping', {
}); });
} }
}, },
special_character: function(frm){ special_character: function (frm) {
var regex = /[!@#$%^&*()_+\=\[\]{};'`~:"\\|,.<>\/?]+/; var regex = /[!@#$%^&*()_+\=\[\]{};'`~:"\\|,.<>\/?]+/;
for (var i = 0; i < cur_frm.doc.system_sub_systems.length; i++) { for (var i = 0; i < cur_frm.doc.system_sub_systems.length; i++) {
if (regex.test(cur_frm.doc.system_sub_systems[i].rts) === true) { if (regex.test(cur_frm.doc.system_sub_systems[i].rts) === true) {
@ -449,7 +449,8 @@ frappe.ui.form.on('System Mapping_Sub System', {
estimate_time: function (frm, cdt, cdn) { fn_updateProceduteStatus(frm, cdt, cdn) }, estimate_time: function (frm, cdt, cdn) { fn_updateProceduteStatus(frm, cdt, cdn) },
rts: function (frm, cdt, cdn) { rts: function (frm, cdt, cdn) {
frm.trigger('special_character'); frm.trigger('special_character');
fn_updateProceduteStatus(frm, cdt, cdn) }, fn_updateProceduteStatus(frm, cdt, cdn)
},
cover_image: function (frm, cdt, cdn) { fn_updateProceduteStatus(frm, cdt, cdn) }, cover_image: function (frm, cdt, cdn) { fn_updateProceduteStatus(frm, cdt, cdn) },
mat: function (frm, cdt, cdn) { mat: function (frm, cdt, cdn) {
var res_mat = []; var res_mat = [];

11
smart_service/transactions/doctype/system_mapping/system_mapping.json

@ -27,7 +27,8 @@
"config_system_level_section", "config_system_level_section",
"system_filter", "system_filter",
"system_sub_systems", "system_sub_systems",
"systems_assets" "systems_assets",
"loader"
], ],
"fields": [ "fields": [
{ {
@ -135,6 +136,7 @@
{ {
"fieldname": "system_filter", "fieldname": "system_filter",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 1,
"label": "System Filter" "label": "System Filter"
}, },
{ {
@ -168,11 +170,16 @@
"label": "Vehicle", "label": "Vehicle",
"options": "Vehicle", "options": "Vehicle",
"read_only": 1 "read_only": 1
},
{
"fieldname": "loader",
"fieldtype": "HTML",
"label": "Loader"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2022-05-31 12:01:37.798339", "modified": "2023-11-10 10:46:28.132993",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "System Mapping", "name": "System Mapping",

Loading…
Cancel
Save