Merge branch 'develop' into sla-enhancements
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index f62df20..c7efb8a 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -71,6 +71,15 @@
 				"compare_fields": [["project", "="], ["item_code", "="],
 					["uom", "="], ["conversion_factor", "="]],
 				"is_child_table": True
+			},
+			"Material Request": {
+				"ref_dn_field": "material_request",
+				"compare_fields": [["company", "="]],
+			},
+			"Material Request Item": {
+				"ref_dn_field": "material_request_item",
+				"compare_fields": [["project", "="], ["item_code", "="]],
+				"is_child_table": True
 			}
 		})
 
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 608e537..89b48f0 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -349,7 +349,7 @@
 			})
 
 			if not rm.rate:
-				rm.rate = get_valuation_rate(raw_material_data.item_code, self.supplier_warehouse,
+				rm.rate = get_valuation_rate(raw_material_data.rm_item_code, self.supplier_warehouse,
 					self.doctype, self.name, currency=self.company_currency, company=self.company)
 
 		rm.amount = qty * flt(rm.rate)