[Fix] Fetch Serial No by default for  Delivery Note Item
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index f298bc8..11bf945 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -11,6 +11,7 @@
 from frappe.utils import flt, cint
 from frappe.model.document import Document
 
+
 class MultiplePricingRuleConflict(frappe.ValidationError): pass
 
 class PricingRule(Document):
@@ -113,8 +114,19 @@
 		args_copy = copy.deepcopy(args)
 		args_copy.update(item)
 		out.append(get_pricing_rule_for_item(args_copy))
-
+		out.append(get_serial_no_for_item(args_copy))
 	return out
+	
+def get_serial_no_for_item(args):
+	from erpnext.stock.get_item_details import get_serial_no
+	item_details = frappe._dict({
+		"doctype": args.doctype,
+		"name": args.name,
+		"serial_no": args.serial_no
+	})
+	if args.get("parenttype") in ("Sales Invoice", "Delivery Note"):
+		item_details.serial_no = get_serial_no(args)
+	return item_details
 
 def get_pricing_rule_for_item(args):
 	if args.get("parenttype") == "Material Request": return {}
@@ -311,4 +323,4 @@
 	elif args.customer:
 		args.transaction_type = "selling"
 	else:
-		args.transaction_type = "buying"
+		args.transaction_type = "buying"
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 6c03706..954b03b 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -736,7 +736,9 @@
 					"qty": d.qty,
 					"parenttype": d.parenttype,
 					"parent": d.parent,
-					"pricing_rule": d.pricing_rule
+					"pricing_rule": d.pricing_rule,
+					"warehouse": d.warehouse,
+					"serial_no": d.serial_no
 				});
 
 				// if doctype is Quotation Item / Sales Order Iten then add Margin Type and rate in item_list
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index 97eca54..fc3cb3d 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -206,11 +206,13 @@
 
 		if(item.item_code && item.warehouse) {
 			return this.frm.call({
-				method: "erpnext.stock.get_item_details.get_bin_details",
+				method: "erpnext.stock.get_item_details.get_bin_details_and_serial_nos",
 				child: item,
 				args: {
 					item_code: item.item_code,
 					warehouse: item.warehouse,
+					qty: item.qty,
+					serial_no:item.serial_no
 				},
 				callback:function(r){
 					if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
@@ -375,4 +377,4 @@
 			})
 		}
 	}
-})
+})
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 81b5c1b..a5a6ced 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -502,7 +502,7 @@
 				'qty'		: d.qty
 			};
 			frappe.call({
-				method: "erpnext.stock.doctype.stock_entry.stock_entry.get_serial_no",
+				method: "erpnext.stock.get_item_details.get_serial_no",
 				args: {"args": args},
 				callback: function(r) {
 					if (!r.exe){
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 65b9d26..c5a03e6 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -8,7 +8,7 @@
 from frappe.utils import cstr, cint, flt, comma_or, getdate, nowdate, formatdate, format_time
 from erpnext.stock.utils import get_incoming_rate
 from erpnext.stock.stock_ledger import get_previous_sle, NegativeStockError
-from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor, process_args, get_serial_nos_by_fifo
+from erpnext.stock.get_item_details import get_bin_details, get_default_cost_center, get_conversion_factor
 from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
 import json
 
@@ -867,17 +867,4 @@
 			"basic_rate" : get_incoming_rate(args)
 		}
 
-	return ret
-
-@frappe.whitelist()
-def get_serial_no(args):
-	if isinstance(args, basestring):
-		args = json.loads(args)
-	args = frappe._dict(args)
-
-	if args.get('warehouse'):
-		if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1:
-			args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')})
-			args = process_args(args)
-			serial_no = get_serial_nos_by_fifo(args)
-			return serial_no
\ No newline at end of file
+	return ret
\ No newline at end of file
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index f8410af..f16ebd5 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -43,7 +43,7 @@
 	get_party_item_code(args, item_doc, out)
 
 	if out.get("warehouse"):
-		out.update(get_bin_details(args.item_code, out.warehouse))
+		out.update(get_bin_details_and_serial_nos(args.item_code, out.warehouse, args.qty, args.serial_no))	
 
 	if frappe.db.exists("Product Bundle", args.item_code):
 		valuation_rate = 0.0
@@ -74,8 +74,7 @@
 	out.update(get_pricing_rule_for_item(args))
 
 	if args.get("doctype") in ("Sales Invoice", "Delivery Note"):
-		if item_doc.has_serial_no == 1 and not args.serial_no:
-			out.serial_no = get_serial_nos_by_fifo(args)
+		out.serial_no = get_serial_no(out)
 
 	if args.transaction_date and item.lead_time_days:
 		out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
@@ -375,8 +374,21 @@
 @frappe.whitelist()
 def get_bin_details(item_code, warehouse):
 	return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
-		["projected_qty", "actual_qty"], as_dict=True) \
-		or {"projected_qty": 0, "actual_qty": 0}
+			["projected_qty", "actual_qty"], as_dict=True) \
+			or {"projected_qty": 0, "actual_qty": 0}
+
+@frappe.whitelist()
+def get_serial_no_details(item_code, warehouse, qty, serial_no):
+	args = frappe._dict({"item_code":item_code, "warehouse":warehouse, "qty":qty, "serial_no":serial_no})
+	serial_no = get_serial_no(args)
+	return {'serial_no': serial_no}
+	
+@frappe.whitelist()
+def get_bin_details_and_serial_nos(item_code, warehouse, qty, serial_no):
+	bin_details_and_serial_nos = {}
+	bin_details_and_serial_nos.update(get_bin_details(item_code, warehouse))
+	bin_details_and_serial_nos.update(get_serial_no_details(item_code, warehouse, qty, serial_no))
+	return bin_details_and_serial_nos
 
 @frappe.whitelist()
 def get_batch_qty(batch_no,warehouse,item_code):
@@ -512,3 +524,17 @@
 
 	return out
 
+@frappe.whitelist()
+def get_serial_no(args):
+	if isinstance(args, basestring):
+		args = json.loads(args)
+		args = frappe._dict(args)
+
+	if args.get('warehouse') and args.get('qty') and args.get('item_code'):
+		
+		if frappe.get_value('Item', {'item_code': args.item_code}, "has_serial_no") == 1:
+			print "I am in too"
+			args = json.dumps({"item_code": args.get('item_code'),"warehouse": args.get('warehouse'),"qty": args.get('qty')})
+			args = process_args(args)
+			serial_no = get_serial_nos_by_fifo(args)
+			return serial_no