From f0c3f0d0be492ecd03c5994a2f7d3b9e3e435fa5 Mon Sep 17 00:00:00 2001 From: Kavin <78342682+kavin0411@users.noreply.github.com> Date: Tue, 14 Oct 2025 13:14:39 +0530 Subject: [PATCH] fix: swap warehouse labels for return entry --- erpnext/public/js/utils/sales_common.js | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index ef0848f4949..8fd0518f5a5 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -113,6 +113,7 @@ erpnext.sales_common = { ); this.toggle_editable_price_list_rate(); + this.change_warehouse_labels_for_return(); } company() { @@ -504,6 +505,33 @@ erpnext.sales_common = { this.frm.set_value("discount_amount", 0); this.frm.set_value("additional_discount_percentage", 0); } + + is_return() { + let reset = !this.frm.doc.is_return; + this.change_warehouse_labels_for_return(reset); + } + + change_warehouse_labels_for_return(reset) { + // swap source and target warehouse labels for return + let source_warehouse_label = __("Source Warehouse"); + let target_warehouse_label = __("Set Target Warehouse"); + + if (this.frm.doc.doctype == "Delivery Note") { + source_warehouse_label = __("Set Source Warehouse"); + } + + if (reset) { + // reset to original labels + this.frm.set_df_property("set_warehouse", "label", source_warehouse_label); + this.frm.set_df_property("set_target_warehouse", "label", target_warehouse_label); + return; + } + + if (this.frm.doc.is_return) { + this.frm.set_df_property("set_warehouse", "label", target_warehouse_label); + this.frm.set_df_property("set_target_warehouse", "label", source_warehouse_label); + } + } }; }, };