From ffb411d9e2a0162d6cf168de504bbd990ec0e0f7 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Thu, 27 Dec 2018 14:12:05 +0530 Subject: [PATCH] Validation while updating items in sales order --- erpnext/controllers/accounts_controller.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 86ceb2e4abf..56ae25e92b3 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1073,6 +1073,10 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name): data = json.loads(trans_items) for d in data: child_item = frappe.get_doc(parent_doctype + ' Item', d.get("docname")) + + if flt(d.get("qty")) < child_item.delivered_qty: + frappe.throw(_("Cannot set quantity less than delivered quantity")) + child_item.qty = flt(d.get("qty")) if child_item.billed_amt > (flt(d.get("rate")) * flt(d.get("qty"))):