From b1454cdf9fa370f84e1a7682ad9f30cd9ac4ddfe Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 9 Sep 2015 17:59:48 +0530 Subject: [PATCH] [fix] fix planned qty --- erpnext/patches/v6_0/fix_planned_qty.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/patches/v6_0/fix_planned_qty.py b/erpnext/patches/v6_0/fix_planned_qty.py index b523350e8d..e8ed1d0530 100644 --- a/erpnext/patches/v6_0/fix_planned_qty.py +++ b/erpnext/patches/v6_0/fix_planned_qty.py @@ -6,8 +6,9 @@ import frappe from erpnext.stock.stock_balance import get_planned_qty, update_bin_qty def execute(): - for item_code, warehouse in frappe.db.sql("""select distinct production_item, fg_warehouse + for item_code, warehouse in frappe.db.sql("""select distinct production_item, fg_warehouse from `tabProduction Order`"""): - update_bin_qty(item_code, warehouse, { - "planned_qty": get_planned_qty(item_code, warehouse) - }) \ No newline at end of file + if frappe.db.exists("Item", item_code) and frappe.db.exists("Warehouse", warehouse): + update_bin_qty(item_code, warehouse, { + "planned_qty": get_planned_qty(item_code, warehouse) + })