From cdf631b9de4b0351c4dc2613e1709e0d464ea69d Mon Sep 17 00:00:00 2001 From: Devin Slauenwhite Date: Wed, 29 Jun 2022 02:36:47 -0400 Subject: [PATCH] fix: validate item dashboard material transfer entry (#31473) --- erpnext/stock/dashboard/item_dashboard.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index c9d5f61f22..6e7622c067 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -260,6 +260,16 @@ erpnext.stock.move_item = function (item, source, target, actual_qty, rate, call } dialog.set_primary_action(__('Create Stock Entry'), function () { + if (source && (dialog.get_value("qty") == 0 || dialog.get_value("qty") > actual_qty)) { + frappe.msgprint(__("Quantity must be greater than zero, and less or equal to {0}", [actual_qty])); + return; + } + + if (dialog.get_value("source") === dialog.get_value("target")) { + frappe.msgprint(__("Source and target warehouse must be different")); + return; + } + frappe.model.with_doctype('Stock Entry', function () { let doc = frappe.model.get_new_doc('Stock Entry'); doc.from_warehouse = dialog.get_value('source');