Added validation for update items in purchase order as well

This commit is contained in:
deepeshgarg007 2018-12-27 15:56:51 +05:30
parent ffb411d9e2
commit 77cde832d6

View File

@ -1074,9 +1074,12 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name):
for d in data: for d in data:
child_item = frappe.get_doc(parent_doctype + ' Item', d.get("docname")) child_item = frappe.get_doc(parent_doctype + ' Item', d.get("docname"))
if flt(d.get("qty")) < child_item.delivered_qty: if parent_doctype == "Sales Order" and flt(d.get("qty")) < child_item.delivered_qty:
frappe.throw(_("Cannot set quantity less than delivered quantity")) frappe.throw(_("Cannot set quantity less than delivered quantity"))
if parent_doctype == "Purchase Order" and flt(d.get("qty")) < child_item.received_qty:
frappe.throw(_("Cannot set quantity less than received quantity"))
child_item.qty = flt(d.get("qty")) child_item.qty = flt(d.get("qty"))
if child_item.billed_amt > (flt(d.get("rate")) * flt(d.get("qty"))): if child_item.billed_amt > (flt(d.get("rate")) * flt(d.get("qty"))):