feat: Trigger rule application from client side
- Table is reset and overwritten with applied rules on checkbox trigger - Sider fixes
This commit is contained in:
@@ -2029,3 +2029,33 @@ erpnext.show_serial_batch_selector = function (frm, d, callback, on_close, show_
|
||||
}, show_dialog);
|
||||
});
|
||||
}
|
||||
|
||||
erpnext.apply_putaway_rule = (frm) => {
|
||||
if (!frm.doc.company) {
|
||||
frappe.throw({message: __("Please select a Company first."), title: __("Mandatory")});
|
||||
}
|
||||
if (!frm.doc.items.length) return;
|
||||
|
||||
frappe.call({
|
||||
method: "erpnext.stock.doctype.putaway_rule.putaway_rule.apply_putaway_rule",
|
||||
args: {
|
||||
doctype: frm.doctype,
|
||||
items: frm.doc.items,
|
||||
company: frm.doc.company,
|
||||
sync: true
|
||||
},
|
||||
callback: (result) => {
|
||||
if (!result.exc && result.message) {
|
||||
frm.clear_table("items");
|
||||
|
||||
let items = result.message;
|
||||
items.forEach((row) => {
|
||||
delete row["name"];
|
||||
let child = frm.add_child("items");
|
||||
Object.assign(child, row);
|
||||
});
|
||||
frm.get_field("items").grid.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user