mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 04:45:09 +00:00
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
@@ -807,43 +807,45 @@ class StockEntry(StockController):
|
|||||||
and target to ensure a meaningful transfer is occurring.
|
and target to ensure a meaningful transfer is occurring.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
frappe.ValidationError: If warehouses are same and no inventory dimensions differ
|
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 frappe.get_single_value("Stock Settings", "validate_material_transfer_warehouses"):
|
||||||
if self.purpose == "Material Transfer":
|
from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions
|
||||||
for item in self.items:
|
|
||||||
if cstr(item.s_warehouse) == cstr(item.t_warehouse):
|
inventory_dimensions = get_inventory_dimensions()
|
||||||
if not inventory_dimensions:
|
if self.purpose == "Material Transfer":
|
||||||
frappe.throw(
|
for item in self.items:
|
||||||
_(
|
if cstr(item.s_warehouse) == cstr(item.t_warehouse):
|
||||||
"Row #{0}: Source and Target Warehouse cannot be the same for Material Transfer"
|
if not inventory_dimensions:
|
||||||
).format(item.idx),
|
|
||||||
title=_("Invalid Source and Target Warehouse"),
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
difference_found = False
|
|
||||||
for dimension in inventory_dimensions:
|
|
||||||
fieldname = (
|
|
||||||
dimension.source_fieldname
|
|
||||||
if dimension.source_fieldname.startswith("to_")
|
|
||||||
else f"to_{dimension.source_fieldname}"
|
|
||||||
)
|
|
||||||
if (
|
|
||||||
item.get(dimension.source_fieldname)
|
|
||||||
and item.get(fieldname)
|
|
||||||
and item.get(dimension.source_fieldname) != item.get(fieldname)
|
|
||||||
):
|
|
||||||
difference_found = True
|
|
||||||
break
|
|
||||||
if not difference_found:
|
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Row #{0}: Source, Target Warehouse and Inventory Dimensions cannot be the exact same for Material Transfer"
|
"Row #{0}: Source and Target Warehouse cannot be the same for Material Transfer"
|
||||||
).format(item.idx),
|
).format(item.idx),
|
||||||
title=_("Invalid Source and Target Warehouse"),
|
title=_("Invalid Source and Target Warehouse"),
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
difference_found = False
|
||||||
|
for dimension in inventory_dimensions:
|
||||||
|
fieldname = (
|
||||||
|
dimension.source_fieldname
|
||||||
|
if dimension.source_fieldname.startswith("to_")
|
||||||
|
else f"to_{dimension.source_fieldname}"
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
item.get(dimension.source_fieldname)
|
||||||
|
and item.get(fieldname)
|
||||||
|
and item.get(dimension.source_fieldname) != item.get(fieldname)
|
||||||
|
):
|
||||||
|
difference_found = True
|
||||||
|
break
|
||||||
|
if not difference_found:
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Row #{0}: Source, Target Warehouse and Inventory Dimensions cannot be the exact same for Material Transfer"
|
||||||
|
).format(item.idx),
|
||||||
|
title=_("Invalid Source and Target Warehouse"),
|
||||||
|
)
|
||||||
|
|
||||||
def get_matched_items(self, item_code):
|
def get_matched_items(self, item_code):
|
||||||
for row in self.items:
|
for row in self.items:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"show_barcode_field",
|
"show_barcode_field",
|
||||||
"clean_description_html",
|
"clean_description_html",
|
||||||
"allow_internal_transfer_at_arms_length_price",
|
"allow_internal_transfer_at_arms_length_price",
|
||||||
|
"validate_material_transfer_warehouses",
|
||||||
"serial_and_batch_item_settings_tab",
|
"serial_and_batch_item_settings_tab",
|
||||||
"section_break_7",
|
"section_break_7",
|
||||||
"allow_existing_serial_no",
|
"allow_existing_serial_no",
|
||||||
@@ -530,6 +531,13 @@
|
|||||||
"label": "Update Price List Based On",
|
"label": "Update Price List Based On",
|
||||||
"mandatory_depends_on": "eval: doc.auto_insert_price_list_rate_if_missing",
|
"mandatory_depends_on": "eval: doc.auto_insert_price_list_rate_if_missing",
|
||||||
"options": "Rate\nPrice List Rate"
|
"options": "Rate\nPrice List Rate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"description": "If enabled, the source and target warehouse in the Material Transfer Stock Entry must be different else an error will be thrown. If inventory dimensions are present, same source and target warehouse can be allowed but atleast any one of the inventory dimension fields must be different.",
|
||||||
|
"fieldname": "validate_material_transfer_warehouses",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Validate Material Transfer Warehouses"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@@ -537,8 +545,8 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-10-17 18:32:35.829395",
|
"modified": "2025-11-11 11:35:39.864923",
|
||||||
"modified_by": "hello@aerele.in",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Settings",
|
"name": "Stock Settings",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
@@ -563,4 +571,4 @@
|
|||||||
"sort_order": "ASC",
|
"sort_order": "ASC",
|
||||||
"states": [],
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class StockSettings(Document):
|
|||||||
update_price_list_based_on: DF.Literal["Rate", "Price List Rate"]
|
update_price_list_based_on: DF.Literal["Rate", "Price List Rate"]
|
||||||
use_naming_series: DF.Check
|
use_naming_series: DF.Check
|
||||||
use_serial_batch_fields: DF.Check
|
use_serial_batch_fields: DF.Check
|
||||||
|
validate_material_transfer_warehouses: DF.Check
|
||||||
valuation_method: DF.Literal["FIFO", "Moving Average", "LIFO"]
|
valuation_method: DF.Literal["FIFO", "Moving Average", "LIFO"]
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user