Item Default fixes
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index ad13447..3a47374 100755
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -168,9 +168,9 @@
 			i.has_serial_no, i.is_stock_item, i.brand, i.stock_uom, i.image,
 			id.expense_account, id.selling_cost_center, id.default_warehouse
 		from
-			`tabItem` i, `tabItem Default` id
+			`tabItem` i LEFT JOIN `tabItem Default` id ON id.parent = i.name
 		where
-			id.parent = i.name and i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
+			i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
 			and id.company = %s {cond}
 		""".format(cond=cond), tuple(args_list), as_dict=1)
 
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 13baf6f..83fe46a 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -217,7 +217,8 @@
 		raw_materials_cost = 0
 		items = list(set([d.item_code for d in bom_items]))
 		item_wh = frappe._dict(frappe.db.sql("""select i.item_code, id.default_warehouse
-			from `tabItem` i, `tabItem Default` id where id.company=%s and i.name in ({0})"""
+			from `tabItem` i, `tabItem Default` id
+			where id.parent=i.name and id.company=%s and i.name in ({0})"""
 			.format(", ".join(["%s"] * len(items))), [self.company] + items))
 
 		for bom_item in bom_items:
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index bbf8f71..c09d989 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -549,14 +549,14 @@
 				item_default.buying_cost_center as cost_center
 				{select_columns}
 			from
-				`tab{table}` bom_item, `tabBOM` bom, `tabItem` item, `tabItem Default` item_default
+				`tab{table}` bom_item
+				JOIN `tabBOM` bom ON bom_item.parent = bom.name
+				JOIN `tabItem` item ON item.name = bom_item.item_code
+				LEFT JOIN `tabItem Default` item_default ON item_default.parent = item.name
 			where
 				bom_item.docstatus < 2
-				and item_default.parent = item.name
 				and item_default.company = %(company)s
 				and bom.name = %(bom)s
-				and bom_item.parent = bom.name
-				and item.name = bom_item.item_code
 				and is_stock_item = 1
 				{where_conditions}
 				group by item_code, stock_uom
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index 006e542..4b2ae54 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -295,10 +295,13 @@
 						bei.description, bei.stock_uom, item.min_order_qty, bei.source_warehouse,
 						item.default_material_request_type, item.min_order_qty, item_default.default_warehouse
 					from
-						`tabBOM Explosion Item` bei, `tabBOM` bom, `tabItem` item, `tabItem Default` item_default
+						`tabBOM Explosion Item` bei 
+						JOIN `tabBOM` bom ON bom.name = bei.parent
+						JOIN `tabItem` item ON item.name = bei.item_code
+						LEFT JOIN `tabItem Default` item_default ON item_default.parent = item.name
 					where
-						bom.name = bei.parent and item.name = bei.item_code and bei.docstatus < 2 
-						and item_default.parent = item.name and item_default.company=%s
+						bei.docstatus < 2 
+						and item_default.company=%s
 						and bom.name=%s and item.is_stock_item in (1, {0})
 					group by bei.item_code, bei.stock_uom""".format(self.include_non_stock_items),
 					(self.company, data.bom_no), as_dict=1):
@@ -320,11 +323,14 @@
 				bom_item.stock_uom as stock_uom, item.min_order_qty as min_order_qty,
 				item_default.default_warehouse
 			FROM
-				`tabBOM Item` bom_item, `tabBOM` bom, tabItem item, `tabItem Default` item_default
+				`tabBOM Item` bom_item
+				JOIN `tabBOM` bom ON bom.name = bom_item.parent
+				JOIN tabItem item ON bom_item.item_code = item.name
+				LEFT JOIN `tabItem Default` item_default ON item.name = item_default.parent
 			where
-				bom.name = bom_item.parent and bom.name = %(bom)s
-				and bom_item.docstatus < 2 and bom_item.item_code = item.name
-				and item.name = item_default.parent and item_default.company = %(company)s
+				bom.name = %(bom)s
+				and bom_item.docstatus < 2
+				and item_default.company = %(company)s
 				and item.is_stock_item in (1, {0})
 			group by bom_item.item_code""".format(self.include_non_stock_items),{
 				'bom': bom_no,
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 64d7c23..8e4a4ca 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -892,9 +892,9 @@
 			i.item_name, i.description, i.stock_uom, i.name, i.is_stock_item, i.item_code, i.item_group,
 			id.expense_account, id.buying_cost_center, id.default_warehouse, id.selling_cost_center, id.default_supplier
 		from
-			`tabItem` i, `tabItem Default` id
+			`tabItem` i LEFT JOIN `tabItem Default` id ON i.name = id.parent
 		where
-			i.name = id.parent and i.name = %s and id.company = %s
+			i.name = %s and id.company = %s
 	''', (item, company), as_dict=1)
 	if item_defaults:
 		return item_defaults[0]
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index 7ca5ead..04b4761 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -19,8 +19,10 @@
 		where t2.new_item_code=%s and t1.parent = t2.name order by t1.idx""", item_code, as_dict=1)
 
 def get_packing_item_details(item, company):
-	return frappe.db.sql("""select i.item_name, i.description, i.stock_uom, id.default_warehouse
-		from `tabItem` i, `tabItem Default` id where id.parent=i.name and i.name = %s and id.company""",
+	return frappe.db.sql("""
+		select i.item_name, i.description, i.stock_uom, id.default_warehouse
+		from `tabItem` i LEFT JOIN `tabItem Default` id ON id.parent=i.name
+		where i.name = %s and id.company""",
 		(item, company), as_dict = 1)[0]
 
 def get_bin_qty(item, warehouse):
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index c3b9843..13b6ce5 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -566,8 +566,8 @@
 		item = frappe.db.sql("""select i.stock_uom, i.description, i.image, i.item_name, i.item_group,
 				i.has_batch_no, i.sample_quantity, i.has_serial_no,
 				id.expense_account, id.buying_cost_center
-			from `tabItem` i, `tabItem Default` id
-			where i.name=%s and i.name=id.parent and id.company=%s
+			from `tabItem` i LEFT JOIN `tabItem Default` id ON i.name=id.parent
+			where i.name=%s and id.company=%s
 				and i.disabled=0
 				and (i.end_of_life is null or i.end_of_life='0000-00-00' or i.end_of_life > %s)""",
 			(args.get('item_code'), self.company, nowdate()), as_dict = 1)