From 0dae9f316a71a919b13c7fe16cd374f1a1b74beb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 5 Aug 2013 15:29:35 +0530 Subject: [PATCH] [bom] [stock entry] Bug Fix for direct BOM entries --- stock/doctype/stock_entry/stock_entry.py | 14 ++++++++++---- stock/doctype/stock_entry/stock_entry.txt | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index c92f1074e5..66d1dbf7c2 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -438,6 +438,7 @@ class DocType(StockController): def get_items(self): self.doclist = self.doc.clear_table(self.doclist, 'mtn_details', 1) + pro_obj = None if self.doc.production_order: # common validations pro_obj = get_obj('Production Order', self.doc.production_order) @@ -456,7 +457,8 @@ class DocType(StockController): else: item_dict = self.get_bom_raw_materials(self.doc.fg_completed_qty) for item in item_dict.values(): - item["from_warehouse"] = pro_obj.doc.wip_warehouse + if pro_obj: + item["from_warehouse"] = pro_obj.doc.wip_warehouse item["to_warehouse"] = "" # add raw materials to Stock Entry Detail table @@ -481,8 +483,12 @@ class DocType(StockController): item = webnotes.conn.sql("""select item, description, uom from `tabBOM` where name=%s""", (self.doc.bom_no,), as_dict=1) self.add_to_stock_entry_detail({ - item[0]["item"] : - [self.doc.fg_completed_qty, item[0]["description"], item[0]["uom"]] + item[0]["item"] : { + "qty": self.doc.fg_completed_qty, + "description": item[0]["description"], + "stock_uom": item[0]["uom"], + "from_warehouse": "" + } }, bom_no=self.doc.bom_no) self.get_stock_and_rate() @@ -604,7 +610,7 @@ class DocType(StockController): for d in item_dict: se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', self.doclist) - se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse) + se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse) se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse) se_child.item_code = cstr(d) se_child.description = item_dict[d]["description"] diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt index 682c054f83..dac6e70182 100644 --- a/stock/doctype/stock_entry/stock_entry.txt +++ b/stock/doctype/stock_entry/stock_entry.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-09 11:43:55", "docstatus": 0, - "modified": "2013-07-05 14:56:06", + "modified": "2013-08-05 15:28:09", "modified_by": "Administrator", "owner": "Administrator" }, @@ -298,11 +298,11 @@ "read_only": 0 }, { - "depends_on": "eval:(doc.purpose!==\"Sales Return\" || doc.purpose!==\"Purchase Return\")", + "depends_on": "eval:(doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")", "doctype": "DocField", "fieldname": "sb1", "fieldtype": "Section Break", - "label": "Reference", + "label": "From Bill of Materials", "read_only": 0 }, {