From cf7f72e586674401282c308ab0d3fe11c55f9033 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 7 Jul 2017 15:09:57 +0530 Subject: [PATCH] frappe call only when there is item --- .../production_order/production_order.js | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js index b2f32126aad..a988112bedf 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.js +++ b/erpnext/manufacturing/doctype/production_order/production_order.js @@ -151,26 +151,28 @@ frappe.ui.form.on("Production Order", { }, production_item: function(frm) { - frappe.call({ - method: "erpnext.manufacturing.doctype.production_order.production_order.get_item_details", - args: { - item: frm.doc.production_item, - project: frm.doc.project - }, - callback: function(r) { - if(r.message) { - erpnext.in_production_item_onchange = true; - $.each(["description", "stock_uom", "project", "bom_no"], function(i, field) { - frm.set_value(field, r.message[field]); - }); + if (frm.doc.production_item) { + frappe.call({ + method: "erpnext.manufacturing.doctype.production_order.production_order.get_item_details", + args: { + item: frm.doc.production_item, + project: frm.doc.project + }, + callback: function(r) { + if(r.message) { + erpnext.in_production_item_onchange = true; + $.each(["description", "stock_uom", "project", "bom_no"], function(i, field) { + frm.set_value(field, r.message[field]); + }); - if(r.message["set_scrap_wh_mandatory"]){ - frm.toggle_reqd("scrap_warehouse", true); + if(r.message["set_scrap_wh_mandatory"]){ + frm.toggle_reqd("scrap_warehouse", true); + } + erpnext.in_production_item_onchange = false; } - erpnext.in_production_item_onchange = false; } - } - }); + }); + } }, project: function(frm) {