Merge https://github.com/frappe/erpnext into purchase-invoice-fix
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 9d85cdb..fb991ce 100755
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -117,7 +117,7 @@
    "search_index": 1
   }, 
   {
-   "description": "If not applicable please enter: NA", 
+   "description": "", 
    "fieldname": "bill_no", 
    "fieldtype": "Data", 
    "in_filter": 1, 
@@ -127,7 +127,7 @@
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 0, 
-   "reqd": 1, 
+   "reqd": 0, 
    "search_index": 1
   }, 
   {
@@ -758,7 +758,7 @@
  "icon": "icon-file-text", 
  "idx": 1, 
  "is_submittable": 1, 
- "modified": "2014-08-12 05:25:16.261614", 
+ "modified": "2014-08-19 12:01:12.133942", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Purchase Invoice", 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index af7c85a..956dacb 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -47,7 +47,6 @@
 		self.pr_required()
 		self.check_active_purchase_items()
 		self.check_conversion_rate()
-		self.validate_bill_no()
 		self.validate_credit_acc()
 		self.clear_unallocated_advances("Purchase Invoice Advance", "advance_allocation_details")
 		self.check_for_acc_head_of_supplier()
@@ -61,6 +60,14 @@
 		self.update_valuation_rate("entries")
 		self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount",
 			"purchase_receipt_details")
+		self.create_remarks()
+
+	def create_remarks(self):
+		if not self.remarks:
+			if self.bill_no and self.bill_date:
+				self.remarks = _("Against Supplier Invoice {0} dated {1}").format(self.bill_no, formatdate(self.bill_date))
+			else:
+				self.remarks = _("No Remarks")
 
 	def set_missing_values(self, for_validate=False):
 		if not self.credit_to:
@@ -88,23 +95,6 @@
 		if (self.currency == default_currency and flt(self.conversion_rate) != 1.00) or not self.conversion_rate or (self.currency != default_currency and flt(self.conversion_rate) == 1.00):
 			throw(_("Conversion rate cannot be 0 or 1"))
 
-	def validate_bill_no(self):
-		if self.bill_no and self.bill_no.lower().strip() \
-				not in ['na', 'not applicable', 'none']:
-			b_no = frappe.db.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
-				where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""",
-				(self.bill_no, self.credit_to, self.name))
-			if b_no and cstr(b_no[0][2]) == cstr(self.is_opening):
-				throw(_("Bill No {0} already booked in Purchase Invoice {1}").format(cstr(b_no[0][0]),
-					cstr(b_no[0][1])))
-
-			if not self.remarks and self.bill_date:
-				self.remarks = (self.remarks or '') + "\n" \
-					+ _("Against Bill {0} dated {1}").format(self.bill_no, formatdate(self.bill_date))
-
-		if not self.remarks:
-			self.remarks = "No Remarks"
-
 	def validate_credit_acc(self):
 		if frappe.db.get_value("Account", self.credit_to, "report_type") != "Balance Sheet":
 			frappe.throw(_("Account must be a balance sheet account"))