From 6423ce2fa7febc4834c31af6d482dd719255fbb0 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 30 Jan 2026 20:05:52 +0530 Subject: [PATCH] fix: validation when more than one FG items in repack stock entry --- erpnext/stock/doctype/stock_entry/stock_entry.py | 15 +++++++++++++++ .../stock/doctype/stock_entry/test_stock_entry.py | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 39db384abd2..f5f724efe42 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -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 diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index ad67ef63f22..ba95b61cd33 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -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)