fix(ux): refresh grid to correctly persist the state of fields

This commit is contained in:
Smit Vora
2026-04-01 08:43:56 +05:30
parent 62d58702a0
commit 3c327d5225

View File

@@ -247,13 +247,16 @@ frappe.ui.form.on("Work Order", {
},
toggle_items_editable(frm) {
if (!frm.doc.__onload?.allow_editing_items) {
frm.set_df_property("required_items", "cannot_delete_rows", true);
frm.set_df_property("required_items", "cannot_add_rows", true);
frm.fields_dict["required_items"].grid.update_docfield_property("item_code", "read_only", 1);
frm.fields_dict["required_items"].grid.update_docfield_property("required_qty", "read_only", 1);
frm.fields_dict["required_items"].grid.refresh();
}
let allow_edit = true;
if (!frm.doc.__onload?.allow_editing_items) allow_edit = false;
frm.set_df_property("required_items", "cannot_delete_rows", !allow_edit);
frm.set_df_property("required_items", "cannot_add_rows", !allow_edit);
const grid = frm.fields_dict["required_items"].grid;
grid.update_docfield_property("item_code", "read_only", !allow_edit);
grid.update_docfield_property("required_qty", "read_only", !allow_edit);
grid.refresh();
},
add_custom_button_to_return_components: function (frm) {