Merge pull request #20445 from rohitwaghchaure/copy_to_warehouse_to_target_warehouse_in_delivery_note_item

fix: to warehouse not set in the customer warehouse
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 2ee6872..67e8bd2 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -92,6 +92,17 @@
 			}, __('Create'));
 			frm.page.set_inner_btn_group_as_primary(__('Create'));
 		}
+	},
+
+	to_warehouse: function(frm) {
+		if(frm.doc.to_warehouse) {
+			["items", "packed_items"].forEach(doctype => {
+				frm.doc[doctype].forEach(d => {
+					frappe.model.set_value(d.doctype, d.name,
+						"target_warehouse", frm.doc.to_warehouse);
+				});
+			});
+		}
 	}
 });