From b44f26d1ba19eec0c26e6a846750fc5922d349b6 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 21 Jul 2015 16:13:02 +0530 Subject: [PATCH] Fixed Max value for update FG Item in Production Order --- .../doctype/production_order/production_order.js | 2 +- erpnext/stock/doctype/stock_entry/stock_entry.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js index 657756d7578..04fcaa5c011 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.js +++ b/erpnext/manufacturing/doctype/production_order/production_order.js @@ -162,7 +162,7 @@ $.extend(cur_frm.cscript, { make_se: function(purpose) { var me = this; var max = (purpose === "Manufacture") ? - flt(this.frm.doc.qty) - flt(this.frm.doc.produced_qty) : + flt(this.frm.doc.material_transferred_for_manufacturing) - flt(this.frm.doc.produced_qty) : flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing); frappe.prompt({fieldtype:"Int", label: __("Qty for {0}", [purpose]), fieldname:"qty", diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 65f9ef06782..c49129da125 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -611,16 +611,16 @@ class StockEntry(StockController): return item_dict def get_transfered_raw_materials(self): - items_dict = frappe.db.sql("""select item_name, item_code, sum(qty) as qty, to_warehouse, from_warehouse, - description, stock_uom, expense_account, cost_center from `tabStock Entry` se,`tabStock Entry Detail` sed + items_dict = frappe.db.sql("""select item_name, item_code, sum(qty) as qty, sed.s_warehouse as s_warehouse, sed.t_warehouse + as t_warehouse, description, stock_uom, expense_account, cost_center from `tabStock Entry` se,`tabStock Entry Detail` sed where se.name = sed.parent and se.docstatus=1 and se.purpose='Material Transfer for Manufacture' and - se.production_order= %s and se.to_warehouse= %s group by sed.item_code""", - (self.production_order, self.from_warehouse), as_dict=1) + se.production_order= %s and ifnull(sed.s_warehouse, '') != '' group by sed.item_code, sed.s_warehouse, sed.t_warehouse""", + self.production_order, as_dict=1) transfered_materials = frappe.db.sql("""select item_code, sum(qty) as qty from `tabStock Entry` se, `tabStock Entry Detail` sed where se.name = sed.parent and se.docstatus=1 and - se.purpose='Manufacture' and se.production_order= %s and se.from_warehouse= %s - group by sed.item_code""", (self.production_order, self.from_warehouse), as_dict=1) + se.purpose='Manufacture' and se.production_order= %s and ifnull(sed.s_warehouse, '') != '' + group by sed.item_code, sed.s_warehouse, sed.t_warehouse""", self.production_order, as_dict=1) transfered_qty= {} for d in transfered_materials: @@ -644,8 +644,8 @@ class StockEntry(StockController): if qty > 0: self.add_to_stock_entry_detail({ item.item_code: { - "to_warehouse": item.to_warehouse, - "from_warehouse": item.from_warehouse, + "to_warehouse": item.t_warehouse, + "from_warehouse": item.s_warehouse, "qty": qty, "item_name": item.item_name, "description": item.description,