fix: toggle consumed qty field based on condition
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 887b15a..cac6bf8 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -41,8 +41,6 @@
 			}
 		});
 
-		frm.set_df_property('supplied_items', 'cannot_add_rows', 1);
-
 	},
 	onload: function(frm) {
 		erpnext.queries.setup_queries(frm, "Warehouse", function() {
@@ -77,6 +75,15 @@
 		}
 
 		frm.events.add_custom_buttons(frm);
+		frm.trigger('toggle_subcontracting_fields');
+	},
+
+	toggle_subcontracting_fields: function(frm) {
+		frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty',
+			'read_only', frm.doc.__onload && frm.doc.__onload.backflush_based_on === 'BOM');
+
+		frm.set_df_property('supplied_items', 'cannot_add_rows', 1);
+		frm.set_df_property('supplied_items', 'cannot_delete_rows', 1);
 	},
 
 	add_custom_buttons: function(frm) {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index b8580f9..264561f 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -102,6 +102,11 @@
 		if self.get("items") and self.apply_putaway_rule and not self.get("is_return"):
 			apply_putaway_rule(self.doctype, self.get("items"), self.company)
 
+	def onload(self):
+		super(PurchaseReceipt, self).onload()
+		self.set_onload("backflush_based_on", frappe.db.get_single_value('Buying Settings',
+			'backflush_raw_materials_of_subcontract_based_on'))
+
 	def validate(self):
 		self.validate_posting_time()
 		super(PurchaseReceipt, self).validate()