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:
marination
2020-12-08 19:11:51 +05:30
parent 0b68243979
commit 0f3cfc502b
9 changed files with 77 additions and 64 deletions

View File

@@ -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();
}
}
});
};