Skip to content

Commit

Permalink
fix: Block 0 Qty via Update Items to be consistent with form validation
Browse files Browse the repository at this point in the history
(cherry picked from commit 0c91543)
  • Loading branch information
marination authored and mergify[bot] committed May 11, 2022
1 parent a761c5c commit 5647875
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2449,11 +2449,21 @@ def get_new_child_item(item_row):
parent_doctype, parent_doctype_name, child_doctype, child_docname, item_row
)

def validate_quantity(child_item, d):
if parent_doctype == "Sales Order" and flt(d.get("qty")) < flt(child_item.delivered_qty):
def validate_quantity(child_item, new_data):
if not flt(new_data.get("qty")):
frappe.throw(
_("Row # {0}: Quantity for Item {1} cannot be zero").format(
new_data.get("idx"), frappe.bold(new_data.get("item_code"))
),
title=_("Invalid Qty"),
)

if parent_doctype == "Sales Order" and flt(new_data.get("qty")) < flt(child_item.delivered_qty):
frappe.throw(_("Cannot set quantity less than delivered quantity"))

if parent_doctype == "Purchase Order" and flt(d.get("qty")) < flt(child_item.received_qty):
if parent_doctype == "Purchase Order" and flt(new_data.get("qty")) < flt(
child_item.received_qty
):
frappe.throw(_("Cannot set quantity less than received quantity"))

data = json.loads(trans_items)
Expand Down

0 comments on commit 5647875

Please sign in to comment.