From adbc67ef11e5437cf35e8e7463440a018709f718 Mon Sep 17 00:00:00 2001 From: pandiyan Date: Wed, 29 Jul 2026 23:12:45 +0530 Subject: [PATCH] fix: guard scio row lookup in stock entry items_add check the result of find() before reading t_warehouse off it. on a 'receive from customer' entry with no row carrying scio_detail, find() returns undefined and items_add throws a typeerror. the throw rejects the serially-run handler chain, so the stock entry controller's own items_add never runs and the new row silently loses its target warehouse, expense account, cost center and serial/batch field defaults. leave t_warehouse unset when no reference row exists, so the rest of the chain still runs. (cherry picked from commit 6e444a18327e13d344bb3fa36c78b58e5fa06d98) # Conflicts: # erpnext/stock/doctype/stock_entry/stock_entry.js --- erpnext/stock/doctype/stock_entry/stock_entry.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index e2db1c7c98a..c2bf64bc9c2 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -964,6 +964,16 @@ frappe.ui.form.on("Stock Entry Detail", { if (item.is_finished_item) { frm.events.set_fg_completed_qty(frm); } +<<<<<<< HEAD +======= + + if (frm.doc.purpose === "Receive from Customer") { + const scio_row = frm.doc.items.find((row) => row.scio_detail); + if (scio_row) { + item.t_warehouse = scio_row.t_warehouse; + } + } +>>>>>>> 6e444a1832 (fix: guard scio row lookup in stock entry items_add) }, set_basic_rate_manually(frm, cdt, cdn) { let row = locals[cdt][cdn];