mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
Merge pull request #30967 from frappe/mergify/bp/version-13-hotfix/pr-30962
fix: Block 0 Qty via Update Items to be consistent with form validation (backport #30962)
This commit is contained in:
@@ -2449,11 +2449,21 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
|
|||||||
parent_doctype, parent_doctype_name, child_doctype, child_docname, item_row
|
parent_doctype, parent_doctype_name, child_doctype, child_docname, item_row
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_quantity(child_item, d):
|
def validate_quantity(child_item, new_data):
|
||||||
if parent_doctype == "Sales Order" and flt(d.get("qty")) < flt(child_item.delivered_qty):
|
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"))
|
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"))
|
frappe.throw(_("Cannot set quantity less than received quantity"))
|
||||||
|
|
||||||
data = json.loads(trans_items)
|
data = json.loads(trans_items)
|
||||||
|
|||||||
Reference in New Issue
Block a user