Hi Team,
How to set the filters to readonly in the MultiSelectDialog?
Reference code:
let d=new frappe.ui.form.MultiSelectDialog({
doctype: “Entity”,
target: frm.doc,
//mandatory to pass the selected_all_containers for container doctype
//customized the MultiSelectDialog for the container doctype
selected_all_containers:all_containers,
size:“large”,
setters: {
warehouse:cur_frm.doc.set_warehouse,
item_code:data.item_code,
status:“Active”,
primary_available_qty:null,
selected:null
},
add_filters_group: 1,
primary_action_label: “Set Entities”,
columns: [“warehouse”,“item_code”,“status”,“primary_available_qty”,“selected”],
get_query() {
let filters = {
docstatus: [‘!=’, 2],
status: [‘=’, ‘Active’],
warehouse: [“=”, cur_frm.doc.set_warehouse],
item_code: [“=”, data.item_code],
}
return {
filters :filters
};
},
action(selections) {
if (selections.length === 0) {
frappe.throw(__(“Please select {0}”, [“Entities”]))
}
frappe.call({
method:“ntpt_erpnext_app.ntpt_erpnext_app.doctype.delivery_note.delivery_note.add_containers”,
args:{
selected_containers:selections,
item:data
},
async:false,
callback: function(r){
if(r.message){
if(data.qty != r.message[1]){
frappe.throw(“Entity qty does not match with given qty”)
}
frappe.model.set_value(cdt,cdn,“container_list”,r.message[0])
frappe.model.set_value(cdt,cdn,“qty”,r.message[1])
}
}
});
d.dialog.hide();
}
});
here i want to make warehouse and item_code fields as readonly
Meet
November 26, 2024, 6:43am
2
@Prasanth_Kumar_J Please update your column with this and check it might be it will be worked
columns = [
{"fieldname": "warehouse", "label": "Warehouse", "fieldtype": "Link", "options": "Warehouse", "read_only": 1},
{"fieldname": "item_code", "label": "Item Code", "fieldtype": "Link", "options": "Item", "read_only": 1},
{"fieldname": "status", "label": "Status", "fieldtype": "Data"},
{"fieldname": "primary_available_qty", "label": "Primary Available Qty", "fieldtype": "Float"},
{"fieldname": "selected", "label": "Selected", "fieldtype": "Check"},
]
Base File Refence Link : frappe/frappe/public/js/frappe/form/multi_select_dialog.js at version-15 · frappe/frappe · GitHub
@Meet
Thanks for the reply
But here I am referring to
setters: {
warehouse:cur_frm.doc.set_warehouse,
item_code:data.item_code,
status:“Active”,
primary_available_qty:null,
selected:null
},
Filters not the columns
Meet
November 26, 2024, 7:30am
4
columns[(index + 1) % 3].push({
fieldtype: df_prop.fieldtype,
label: df_prop.label,
fieldname: setter,
options: df_prop.options,
default: this.setters[setter],
});
in this code you can override and add the read_only : 1 then your code is worked else not work so override the frappe js file and update this code then your query is resolved
I don’t want to override the code as per the documentation it was saying we can set it using read_only_setters . But when using that not able to see those fields in the popup.
https://frappeframework.com/docs/user/en/api/dialog
rahib
November 26, 2024, 12:35pm
6
Try
setters: [
{
fieldtype: "Link",
label: __("Customer"),
options: "Customer",
fieldname: "party_name",
default: me.frm.doc.customer,
read_only: 1
},
],
Haven’t tested. Not entirely sure if it will work.