From 29c46bb311dbacd71a7f7875ceff47eda8060c12 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 6 Mar 2019 14:42:50 +0530 Subject: [PATCH] fix(sales_order.py): handle zero bundle qty --- erpnext/manufacturing/doctype/work_order/work_order.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 9873efa124..947d6931e2 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -282,6 +282,10 @@ class WorkOrder(Document): total_bundle_qty = frappe.db.sql(""" select sum(qty) from `tabProduct Bundle Item` where parent = %s""", (frappe.db.escape(self.product_bundle_item)))[0][0] + if not total_bundle_qty: + # product bundle is 0 (product bundle allows 0 qty for items) + total_bundle_qty = 1 + cond = "product_bundle_item = %s" if self.product_bundle_item else "production_item = %s" qty = frappe.db.sql(""" select sum(qty) from