fix: validation when more than one FG items in repack stock entry

(cherry picked from commit 6423ce2fa7)

# Conflicts:
#	erpnext/stock/doctype/stock_entry/stock_entry.py
This commit is contained in:
Rohit Waghchaure
2026-01-30 20:05:52 +05:30
committed by Mergify
parent 4dfc5671b0
commit fec3a8b511
2 changed files with 24 additions and 0 deletions

View File

@@ -226,6 +226,7 @@ class StockEntry(StockController):
self.validate_job_card_item()
self.set_purpose_for_stock_entry()
self.clean_serial_nos()
self.validate_repack_entry()
if not self.from_bom:
self.fg_completed_qty = 0.0
@@ -245,6 +246,25 @@ class StockEntry(StockController):
self.validate_same_source_target_warehouse_during_material_transfer()
self.validate_raw_materials_exists()
<<<<<<< HEAD
=======
super().validate_subcontracting_inward()
def validate_repack_entry(self):
if self.purpose != "Repack":
return
fg_items = {row.item_code: row for row in self.items if row.is_finished_item}
if len(fg_items) > 1 and not all(row.set_basic_rate_manually for row in fg_items.values()):
frappe.throw(
_(
"When there are multiple finished goods ({0}) in a Repack stock entry, the basic rate for all finished goods must be set manually. To set rate manually, enable the checkbox 'Set Basic Rate Manually' in the respective finished good row."
).format(", ".join(fg_items)),
title=_("Set Basic Rate Manually"),
)
>>>>>>> 6423ce2fa7 (fix: validation when more than one FG items in repack stock entry)
def validate_raw_materials_exists(self):
if self.purpose not in ["Manufacture", "Repack", "Disassemble"]:
return

View File

@@ -413,6 +413,10 @@ class TestStockEntry(FrappeTestCase):
},
)
repack.set_stock_entry_type()
for row in repack.items:
if row.t_warehouse:
row.set_basic_rate_manually = 1
repack.insert()
self.assertEqual(repack.items[1].is_finished_item, 1)