Merge pull request #5618 from rohitwaghchaure/sq_field_and_rfq_fixes

[Fixes] Fixed linked for MR to SQ from RFQ, changed field name in SQI
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index 67ad3c2..eea796a 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -177,11 +177,10 @@
 		},
 		"Request for Quotation Item": {
 			"doctype": "Supplier Quotation Item",
-			"field_map": [
-				["name", "request_for_quotation_item"],
-				["parent", "request_for_quotation"],
-				["uom", "uom"]
-			],
+			"field_map": {
+				"name": "request_for_quotation_item",
+				"parent": "request_for_quotation"
+			},
 		}
 	}, target_doc, postprocess)
 
diff --git a/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.json b/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.json
index 8c6ac91..af3e265 100644
--- a/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.json
+++ b/erpnext/buying/doctype/request_for_quotation_item/request_for_quotation_item.json
@@ -469,11 +469,11 @@
    "in_list_view": 0, 
    "label": "Material Request", 
    "length": 0, 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "options": "Material Request", 
    "permlevel": 0, 
    "precision": "", 
-   "print_hide": 0, 
+   "print_hide": 1, 
    "print_hide_if_no_value": 0, 
    "read_only": 1, 
    "report_hide": 0, 
@@ -519,7 +519,7 @@
    "in_list_view": 0, 
    "label": "Material Request Item", 
    "length": 0, 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "permlevel": 0, 
    "precision": "", 
    "print_hide": 1, 
@@ -626,7 +626,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-06-28 14:25:08.330508", 
+ "modified": "2016-07-01 01:07:59.541478", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Request for Quotation Item", 
diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
index 1275fcd..6ddc728 100644
--- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
+++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
@@ -3,6 +3,7 @@
  "allow_import": 0, 
  "allow_rename": 0, 
  "autoname": "hash", 
+ "beta": 0, 
  "creation": "2013-05-22 12:43:10", 
  "custom": 0, 
  "docstatus": 0, 
@@ -854,16 +855,16 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "prevdoc_docname", 
+   "fieldname": "material_request", 
    "fieldtype": "Link", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "label": "Material Request No", 
+   "label": "Material Request", 
    "length": 0, 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "oldfieldname": "prevdoc_docname", 
    "oldfieldtype": "Link", 
    "options": "Material Request", 
@@ -932,16 +933,16 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "prevdoc_detail_docname", 
+   "fieldname": "material_request_item", 
    "fieldtype": "Data", 
    "hidden": 1, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
-   "label": "Material Request Detail No", 
+   "label": "Material Request Item", 
    "length": 0, 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "oldfieldname": "prevdoc_detail_docname", 
    "oldfieldtype": "Data", 
    "permlevel": 0, 
@@ -1091,20 +1092,23 @@
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 1, 
+ "image_view": 0, 
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-03-25 17:01:59.632826", 
+ "modified": "2016-07-01 01:07:29.202856", 
  "modified_by": "Administrator", 
  "module": "Buying", 
  "name": "Supplier Quotation Item", 
  "owner": "Administrator", 
  "permissions": [], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "sort_field": "modified", 
- "sort_order": "DESC"
+ "sort_order": "DESC", 
+ "track_seen": 0
 }
\ No newline at end of file
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index db4076e..66c7a7e 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -283,3 +283,4 @@
 erpnext.patches.v7_0.remove_doctypes_and_reports
 erpnext.patches.v7_0.set_is_group_for_warehouse
 erpnext.patches.v7_0.update_maintenance_module_in_doctype
+erpnext.patches.v7_0.update_prevdoc_values_for_supplier_quotation_item
diff --git a/erpnext/patches/v7_0/update_prevdoc_values_for_supplier_quotation_item.py b/erpnext/patches/v7_0/update_prevdoc_values_for_supplier_quotation_item.py
new file mode 100644
index 0000000..964b657
--- /dev/null
+++ b/erpnext/patches/v7_0/update_prevdoc_values_for_supplier_quotation_item.py
@@ -0,0 +1,8 @@
+import frappe
+from frappe.utils import cint
+
+def execute():
+	for data in frappe.db.sql(""" select prevdoc_docname, prevdoc_detail_docname, name 
+		from `tabSupplier Quotation Item` where prevdoc_docname is not null""", as_dict=True):
+		frappe.db.set_value("Supplier Quotation Item", data.name, "material_request", data.prevdoc_docname)
+		frappe.db.set_value("Supplier Quotation Item", data.name, "material_request_item", data.prevdoc_detail_docname)
\ No newline at end of file
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index ef1c574..3de62c1 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -321,9 +321,8 @@
 		"Material Request Item": {
 			"doctype": "Supplier Quotation Item",
 			"field_map": {
-				"name": "prevdoc_detail_docname",
-				"parent": "prevdoc_docname",
-				"parenttype": "prevdoc_doctype"
+				"name": "material_request_item",
+				"parent": "material_request"
 			}
 		}
 	}, target_doc, postprocess)