mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 18:21:22 +00:00
chore: add docstring to function (#50329)
This commit is contained in:
@@ -867,15 +867,27 @@ class StockEntry(StockController, SubcontractingInwardController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def validate_same_source_target_warehouse_during_material_transfer(self):
|
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
|
from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions
|
||||||
|
|
||||||
inventory_dimensions = get_inventory_dimensions()
|
inventory_dimensions = get_inventory_dimensions()
|
||||||
if self.purpose == "Material Transfer":
|
if self.purpose == "Material Transfer":
|
||||||
for item in self.items:
|
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:
|
if not inventory_dimensions:
|
||||||
frappe.throw(
|
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"),
|
title=_("Invalid Source and Target Warehouse"),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user