mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-12 17:23:38 +00:00
fix: validation when more than one FG items in repack stock entry
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user