Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/manufacturing/doctype/production_order/production_order.js b/manufacturing/doctype/production_order/production_order.js
index 2ec91e7..5243026 100644
--- a/manufacturing/doctype/production_order/production_order.js
+++ b/manufacturing/doctype/production_order/production_order.js
@@ -91,7 +91,7 @@
 	se.company = doc.company;
 	se.fg_completed_qty = doc.qty - doc.produced_qty;
 	se.bom_no = doc.bom_no;
-	se.use_multi_level_bom = 1;
+	se.use_multi_level_bom = doc.use_multi_level_bom;
 	loaddoc('Stock Entry', se.name);
 }
 
diff --git a/manufacturing/doctype/production_order/production_order.txt b/manufacturing/doctype/production_order/production_order.txt
index 0f94d4e..9266084 100644
--- a/manufacturing/doctype/production_order/production_order.txt
+++ b/manufacturing/doctype/production_order/production_order.txt
@@ -4,7 +4,7 @@
   "docstatus": 0, 
   "creation": "2012-12-20 14:31:18", 
   "modified_by": "Administrator", 
-  "modified": "2012-12-20 15:50:43"
+  "modified": "2012-12-24 18:39:00"
  }, 
  {
   "is_submittable": 1, 
@@ -143,6 +143,14 @@
   "depends_on": "production_item"
  }, 
  {
+  "description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.", 
+  "default": "1", 
+  "doctype": "DocField", 
+  "label": "Use Multi-Level BOM", 
+  "fieldname": "use_multi_level_bom", 
+  "fieldtype": "Check"
+ }, 
+ {
   "read_only": 0, 
   "doctype": "DocField", 
   "label": "More Info", 
diff --git a/patches/november_2012/production_order_patch.py b/patches/november_2012/production_order_patch.py
index e64af59..e6a1192 100644
--- a/patches/november_2012/production_order_patch.py
+++ b/patches/november_2012/production_order_patch.py
@@ -6,4 +6,7 @@
 	
 	webnotes.conn.sql("""update `tabStock Entry` 
 		set use_multi_level_bom = if(consider_sa_items_as_raw_materials='Yes', 0, 1)""")
-	
\ No newline at end of file
+	
+	webnotes.conn.sql("""update `tabProduction Order` 
+		set use_multi_level_bom = if(consider_sa_items_as_raw_materials='Yes', 0, 1)
+		where use_multi_level_bom is null""")
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index deb1bd3..2e26a1a 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -543,6 +543,6 @@
 @webnotes.whitelist()
 def get_production_order_details(production_order):
 	result = webnotes.conn.sql("""select bom_no, 
-		ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty
+		ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom
 		from `tabProduction Order` where name = %s""", production_order, as_dict=1)
 	return result and result[0] or {}
\ No newline at end of file