From 9a78283ecb33d5c901a507e362f3b88193c0e542 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 20:46:57 +0530 Subject: [PATCH] fix: incorrect inventory dimension for material transfer (backport #47592) (#47644) fix: incorrect inventory dimension for material transfer (#47592) (cherry picked from commit 738cb6a0c12fc7d804e058cdc5115519fceec338) Co-authored-by: rohitwaghchaure --- erpnext/controllers/stock_controller.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index f079274528c..3654ad5e6c5 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -892,7 +892,7 @@ class StockController(AccountsController): or sl_dict.actual_qty < 0 and self.get("is_return") ) - and self.doctype in ["Purchase Invoice", "Purchase Receipt"] + and self.doctype in ["Purchase Invoice", "Purchase Receipt", "Stock Entry"] ) or ( ( sl_dict.actual_qty < 0 @@ -902,6 +902,15 @@ class StockController(AccountsController): ) and self.doctype in ["Sales Invoice", "Delivery Note", "Stock Entry"] ): + if self.doctype == "Stock Entry": + if row.get("t_warehouse") == sl_dict.warehouse and sl_dict.get("actual_qty") > 0: + fieldname = f"to_{dimension.source_fieldname}" + if dimension.source_fieldname.startswith("to_"): + fieldname = f"{dimension.source_fieldname}" + + sl_dict[dimension.target_fieldname] = row.get(fieldname) + return + sl_dict[dimension.target_fieldname] = row.get(dimension.source_fieldname) else: fieldname_start_with = "to"