diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index d313c037e02..80571a1d813 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -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 diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 2383fabaf89..f11854f52a9 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -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)