From f7fa394aea779e32f595e1450d22b8a29aea4dab Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 05:33:55 +0000 Subject: [PATCH] fix: negative quantity check in validate_item_qty (backport #54559) (#54572) 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: (cherry picked from commit 63edd5ddc6b6894102fd6d40ea735113022f995c) Co-authored-by: Vinay Mishra <39999379+vinaymishraofficial@users.noreply.github.com> --- erpnext/manufacturing/doctype/blanket_order/blanket_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py index 69e9d8ee14c..21f7fe5bb3e 100644 --- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py +++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py @@ -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))