Merge pull request #5941 from nabinhait/link_formatter

minor fix for item and employee link formatter
diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.json b/erpnext/buying/doctype/quality_inspection/quality_inspection.json
index ba5396c..06246cc 100644
--- a/erpnext/buying/doctype/quality_inspection/quality_inspection.json
+++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.json
@@ -3,10 +3,12 @@
  "allow_import": 0, 
  "allow_rename": 0, 
  "autoname": "naming_series:", 
+ "beta": 0, 
  "creation": "2013-04-30 13:13:03", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
+ "editable_grid": 1, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -16,6 +18,7 @@
    "fieldtype": "Select", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Series", 
@@ -24,6 +27,7 @@
    "options": "QI-", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -40,6 +44,7 @@
    "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Report Date", 
@@ -49,6 +54,7 @@
    "oldfieldtype": "Date", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -64,6 +70,7 @@
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "length": 0, 
@@ -71,6 +78,7 @@
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -86,6 +94,7 @@
    "fieldtype": "Select", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Inspection Type", 
@@ -96,6 +105,7 @@
    "options": "\nIncoming\nOutgoing\nIn Process", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -111,6 +121,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
    "label": "Purchase Receipt No", 
@@ -121,6 +132,7 @@
    "options": "Purchase Receipt", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -136,6 +148,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
    "label": "Delivery Note No", 
@@ -146,6 +159,7 @@
    "options": "Delivery Note", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -161,6 +175,7 @@
    "fieldtype": "Section Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "length": 0, 
@@ -168,6 +183,7 @@
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -183,6 +199,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Item Code", 
@@ -193,6 +210,7 @@
    "options": "Item", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -208,6 +226,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Item Serial No", 
@@ -218,6 +237,7 @@
    "options": "Serial No", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -233,6 +253,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Batch No", 
@@ -243,6 +264,7 @@
    "options": "Batch", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -258,6 +280,7 @@
    "fieldtype": "Float", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Sample Size", 
@@ -267,6 +290,7 @@
    "oldfieldtype": "Currency", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -282,6 +306,7 @@
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "length": 0, 
@@ -289,6 +314,7 @@
    "oldfieldtype": "Column Break", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -305,6 +331,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Item Name", 
@@ -313,6 +340,7 @@
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -328,6 +356,7 @@
    "fieldtype": "Small Text", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
    "label": "Description", 
@@ -337,6 +366,7 @@
    "oldfieldtype": "Small Text", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -353,6 +383,7 @@
    "fieldtype": "Section Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "length": 0, 
@@ -360,6 +391,7 @@
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -376,6 +408,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Inspected By", 
@@ -386,6 +419,7 @@
    "options": "User", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
@@ -401,6 +435,7 @@
    "fieldtype": "Data", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Verified By", 
@@ -410,6 +445,7 @@
    "oldfieldtype": "Data", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -425,6 +461,7 @@
    "fieldtype": "Column Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "length": 0, 
@@ -432,6 +469,7 @@
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -447,6 +485,7 @@
    "fieldtype": "Text", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Remarks", 
@@ -456,6 +495,7 @@
    "oldfieldtype": "Text", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -471,6 +511,7 @@
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 1, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Amended From", 
@@ -481,6 +522,7 @@
    "options": "Quality Inspection", 
    "permlevel": 0, 
    "print_hide": 1, 
+   "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -496,6 +538,7 @@
    "fieldtype": "Section Break", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "", 
@@ -505,6 +548,7 @@
    "options": "Simple", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -520,6 +564,7 @@
    "fieldtype": "Button", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Get Specification Details", 
@@ -528,6 +573,7 @@
    "options": "get_item_specification_details", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -543,6 +589,7 @@
    "fieldtype": "Table", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Readings", 
@@ -553,6 +600,7 @@
    "options": "Quality Inspection Reading", 
    "permlevel": 0, 
    "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -565,13 +613,14 @@
  "hide_toolbar": 0, 
  "icon": "icon-search", 
  "idx": 1, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2015-11-16 06:29:54.786379", 
+ "modified": "2016-07-31 11:42:40.498926", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Quality Inspection", 
@@ -598,7 +647,10 @@
    "write": 1
   }
  ], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
- "search_fields": "item_code, report_date, purchase_receipt_no, delivery_note_no"
+ "search_fields": "item_code, report_date, purchase_receipt_no, delivery_note_no", 
+ "sort_order": "ASC", 
+ "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 6c5f59a..7330889 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -180,7 +180,7 @@
 }
 
 frappe.form.link_formatters['Item'] = function(value, doc) {
-	if(doc.item_name && doc.item_name !== value) {
+	if(doc && doc.item_name && doc.item_name !== value) {
 		return value + ': ' + doc.item_name;
 	} else {
 		return value;
@@ -188,7 +188,7 @@
 }
 
 frappe.form.link_formatters['Employee'] = function(value, doc) {
-	if(doc.employee_name && doc.employee_name !== value) {
+	if(doc && doc.employee_name && doc.employee_name !== value) {
 		return value + ': ' + doc.employee_name;
 	} else {
 		return value;