mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 06:31:48 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user