feat: Apply Putaway Rules within transaction itself

- Added checkbox 'Apply Putaway Rule' in PR and SE
- Added link to rule in child tables
- Rule is applied on Save
- Validation for over receipt
- Apply Rule on Stock Entry as well for Material Transfer and Receipt
This commit is contained in:
marination
2020-12-07 21:35:49 +05:30
parent 1087d97c03
commit fac4035f23
11 changed files with 217 additions and 58 deletions

View File

@@ -524,3 +524,26 @@ erpnext.buying.get_items_from_product_bundle = function(frm) {
dialog.show();
}
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: {
items: frm.doc.items,
company: frm.doc.company
},
callback: (result) => {
if(!result.exc) {
if(result.message) {
frm.doc.items = result.message;
frm.get_field("items").refresh();
}
}
}
});
}