From 34c190a76e0052c9531e2a7bcf1a1a296d7371d9 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 4 Nov 2025 13:57:12 +0530 Subject: [PATCH] chore: add docstring to function --- erpnext/stock/doctype/stock_entry/stock_entry.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 1a35668b347..932f8a4844e 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -867,15 +867,27 @@ class StockEntry(StockController, SubcontractingInwardController): ) def validate_same_source_target_warehouse_during_material_transfer(self): + """ + Validate Material Transfer entries where source and target warehouses are identical. + + For Material Transfer purpose, if an item has the same source and target warehouse, + require that at least one inventory dimension (if configured) differs between source + and target to ensure a meaningful transfer is occurring. + + Raises: + frappe.ValidationError: If warehouses are same and no inventory dimensions differ + """ from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions inventory_dimensions = get_inventory_dimensions() if self.purpose == "Material Transfer": for item in self.items: - if item.s_warehouse == item.t_warehouse: + if cstr(item.s_warehouse) == cstr(item.t_warehouse): if not inventory_dimensions: frappe.throw( - _("Source and Target Warehouse cannot be the same for Material Transfer"), + _( + "Row #{0}: Source and Target Warehouse cannot be the same for Material Transfer" + ).format(item.idx), title=_("Invalid Source and Target Warehouse"), ) else: