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

This commit is contained in:
Rohit Waghchaure
2026-01-30 20:05:52 +05:30
parent 91b1df49a4
commit 6423ce2fa7
2 changed files with 19 additions and 0 deletions

View File

@@ -258,6 +258,7 @@ class StockEntry(StockController, SubcontractingInwardController):
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
@@ -282,6 +283,20 @@ class StockEntry(StockController, SubcontractingInwardController):
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"),
)
def validate_raw_materials_exists(self):
if self.purpose not in ["Manufacture", "Repack", "Disassemble"]:
return

View File

@@ -412,6 +412,10 @@ class TestStockEntry(IntegrationTestCase):
},
)
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)