[doclist] new pattern / [item] pricelist must be unique / [formatter] show null floats as empty string
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index cd822e6..0c25b98 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -47,13 +47,13 @@
 			self.set_total_in_words()
 	
 	def validate_warehouse_belongs_to_company(self):
-		for d in self.doclist.get({"warehouse": True}):
-			warehouse_company = webnotes.conn.get_value("Warehouse", d.warehouse, "company")
-			if warehouse_company and warehouse_company != self.doc.company:
+		for warehouse, company in webnotes.conn.get_values("Warehouse", 
+			self.doclist.get_distinct_values("warehouse"), "company").items():
+			if company and company != self.doc.company:
 				webnotes.msgprint(_("Warehouse must belong to company") + \
-					(": %s (%s, %s)" % (d.warehouse, warehouse_company, self.doc.company)),
+					(": %s (%s, %s)" % (warehouse, company, self.doc.company)),
 					raise_exception=WrongWarehouseCompany)
-	
+
 	def validate_stock_or_nonstock_items(self):
 		items = [d.item_code for d in self.doclist.get({"parentfield": self.fname})]
 		if self.stock_items:
diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py
index 6b6dfb3..c6bf017 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -23,6 +23,7 @@
 from webnotes import msgprint, _
 
 from webnotes.model.controller import DocListController
+
 class DocType(DocListController):
 	def validate(self):
 		if not self.doc.stock_uom:
@@ -124,13 +125,12 @@
 	def check_ref_rate_detail(self):
 		check_list=[]
 		for d in getlist(self.doclist,'ref_rate_details'):
-			if [cstr(d.price_list_name), cstr(d.ref_currency), 
-					cint(d.selling), cint(d.buying)] in check_list:
-				msgprint("Ref Rate is entered twice for Price List : '%s' and Currency : '%s'." % 
-					(d.price_list_name,d.ref_currency), raise_exception=1)
+			if d.price_list_name in check_list:
+				msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list_name,
+					raise_exception= webnotes.DuplicateEntryError)
 			else:
-				check_list.append([cstr(d.price_list_name),cstr(d.ref_currency)])
-	
+				check_list.append(d.price_list_name)
+					
 	def fill_customer_code(self):
 		""" Append all the customer codes and insert into "customer_code" field of item table """
 		cust_code=[]
diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py
index dbbeecc..a59747c 100644
--- a/stock/doctype/item/test_item.py
+++ b/stock/doctype/item/test_item.py
@@ -20,6 +20,14 @@
 
 test_ignore = ["BOM"]
 
+class TestItem(unittest.TestCase):
+	def test_duplicate_price_list(self):
+		item = webnotes.bean(copy=test_records[0])
+		item.doc.item_code = "_Test Item 10"
+		item_price = item.doclist.get({"doctype": "Item Price"})[0]
+		item.doclist.append(webnotes.doc(item_price.fields.copy()))
+		self.assertRaises(webnotes.DuplicateEntryError, item.insert)
+
 test_records = [
 	[{
 		"doctype": "Item",
@@ -45,7 +53,14 @@
 		"warehouse": "_Test Warehouse",
 		"warehouse_reorder_level": 20,
 		"warehouse_reorder_qty": 20
-	}],
+	}, {
+		"doctype": "Item Price",
+		"parentfield": "ref_rate_details",
+		"price_list_name": "_Test Price List",
+		"ref_rate": 100,
+		"ref_currency": "INR"
+	}
+	],
 	[{
 		"doctype": "Item",
 		"item_code": "_Test Item Home Desktop 100",