fix: product bundle child item quantity should be a positive number

(cherry picked from commit 711076d02d)
This commit is contained in:
diptanilsaha
2025-08-14 11:49:09 +05:30
committed by Mergify
parent ad052d72d7
commit f831d45cc3

View File

@@ -32,6 +32,7 @@ class ProductBundle(Document):
def validate(self):
self.validate_main_item()
self.validate_child_items()
self.validate_child_items_qty_non_zero()
from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self, "uom", "qty")
@@ -88,6 +89,15 @@ class ProductBundle(Document):
).format(item.idx, frappe.bold(item.item_code))
)
def validate_child_items_qty_non_zero(self):
for item in self.items:
if item.qty <= 0:
frappe.throw(
_(
"Row #{0}: Quantity cannot be a non-positive number. Please increase the quantity or remove the Item {1}"
).format(item.idx, frappe.bold(item.item_code))
)
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs