From 920e64ded0ca9e1b9fb15f1106dbf78ee8e66b84 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Fri, 17 Jul 2026 13:05:29 +0530 Subject: [PATCH] fix: fall back to the company in-transit warehouse set_transit_warehouse re-tested from_warehouse inside a guard that already requires it, so the Company branch of its ternary was unreachable: with no default on the source warehouse the field stayed empty and Company.default_in_transit_warehouse was silently ignored. Try the warehouse's default first, then the company's. --- erpnext/stock/doctype/stock_entry/stock_entry.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 9469ac48a62..650eeea9891 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -943,11 +943,16 @@ frappe.ui.form.on("Stock Entry", { !frm.doc.to_warehouse && frm.doc.from_warehouse ) { - let dt = frm.doc.from_warehouse ? "Warehouse" : "Company"; - let dn = frm.doc.from_warehouse ? frm.doc.from_warehouse : frm.doc.company; - frappe.db.get_value(dt, dn, "default_in_transit_warehouse", (r) => { + // prefer the source warehouse's in-transit default, then the company's + frappe.db.get_value("Warehouse", frm.doc.from_warehouse, "default_in_transit_warehouse", (r) => { if (r.default_in_transit_warehouse) { frm.set_value("to_warehouse", r.default_in_transit_warehouse); + } else if (frm.doc.company) { + frappe.db.get_value("Company", frm.doc.company, "default_in_transit_warehouse", (res) => { + if (res.default_in_transit_warehouse) { + frm.set_value("to_warehouse", res.default_in_transit_warehouse); + } + }); } }); }