Solution similar to Select Serial Number in Delivery Note:
1) create New Doctype
2) add custom button on New Doctype Table
3) write following script
4) it will filter test records for selcted group and you can add this test record into [New Doctype Table].[Field Name] (like serial number)
frappe.ui.form.on("DocType Item", "custom_button", function(frm, cdt, cdn) {
var test_details = frappe.get_doc(cdt, cdn);
var grid_row = cur_frm.open_grid_row();
//if (job.item_code == "Artwork") {
// job.job_type="New";
// refresh_field("job_type", job.name, job.parentfield);
//}
var d = new frappe.ui.Dialog({
title: __("Add Serial No"),
fields: [
{
"fieldtype": "Link",
"options": "Test Name",
"label": __("Test Name"),
"get_query": function () {
return {
filters: {
test_group:grid_row.doc.test_group
}
}
}
},
{
"fieldtype": "Button",
"label": __("Add")
}
]
});
d.get_input("add").on("click", function() {
var test_name = d.get_value("test_name");
if(test_name) {
var val = (grid_row.doc.test || "").split("\n").concat([test_name]).join("\n");
grid_row.fields_dict.test.set_model_value(val.trim());
}
d.hide();
return false;
});
d.show();
//select test finish
})
1) create New Doctype
2) add custom button on New Doctype Table
3) write following script
4) it will filter test records for selcted group and you can add this test record into [New Doctype Table].[Field Name] (like serial number)
frappe.ui.form.on("DocType Item", "custom_button", function(frm, cdt, cdn) {
var test_details = frappe.get_doc(cdt, cdn);
var grid_row = cur_frm.open_grid_row();
//if (job.item_code == "Artwork") {
// job.job_type="New";
// refresh_field("job_type", job.name, job.parentfield);
//}
var d = new frappe.ui.Dialog({
title: __("Add Serial No"),
fields: [
{
"fieldtype": "Link",
"options": "Test Name",
"label": __("Test Name"),
"get_query": function () {
return {
filters: {
test_group:grid_row.doc.test_group
}
}
}
},
{
"fieldtype": "Button",
"label": __("Add")
}
]
});
d.get_input("add").on("click", function() {
var test_name = d.get_value("test_name");
if(test_name) {
var val = (grid_row.doc.test || "").split("\n").concat([test_name]).join("\n");
grid_row.fields_dict.test.set_model_value(val.trim());
}
d.hide();
return false;
});
d.show();
//select test finish
})
No comments:
Post a Comment