mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 12:38:27 +00:00
fix: negative quantity check in validate_item_qty (#54559)
Fix negative quantity check in validate_item_qty When saving a Blanket Order with a blank qty field in the items table, the following error is raised: TypeError: '<' not supported between instances of 'NoneType' and 'int' Root cause: The validate_item_qty method compares d.qty < 0 directly. When the qty field is left empty, its value is None, and Python cannot compare None with an integer. Fix Wrap d.qty with flt(), which safely converts None (and any non-numeric value) to 0.0 before the comparison. # Before if d.qty < 0: # After if flt(d.qty) < 0:
This commit is contained in:
@@ -120,7 +120,7 @@ class BlanketOrder(Document):
|
||||
|
||||
def validate_item_qty(self):
|
||||
for d in self.items:
|
||||
if d.qty < 0:
|
||||
if flt(d.qty) < 0:
|
||||
frappe.throw(_("Row {0}: Quantity cannot be negative.").format(d.idx))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user