fix: Block 0 Qty via Update Items to be consistent with form validation
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 78645e0..46013bb 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -2451,11 +2451,21 @@
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)