Merge pull request #53647 from frappe/mergify/bp/version-15-hotfix/pr-53645

fix: Adding validation for operation time in BOM (backport #53645)
This commit is contained in:
Nishka Gosalia
2026-03-19 20:21:20 +05:30
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@@ -1019,6 +1019,12 @@ class BOM(WebsiteGenerator):
"Row {0}: Workstation or Workstation Type is mandatory for an operation {1}"
).format(d.idx, d.operation)
)
if not d.time_in_mins or d.time_in_mins <= 0:
frappe.throw(
_("Row {0}: Operation time should be greater than 0 for operation {1}").format(
d.idx, d.operation
)
)
def get_tree_representation(self) -> BOMTree:
"""Get a complete tree representation preserving order of child items."""

View File

@@ -132,6 +132,15 @@ class TestBOM(FrappeTestCase):
self.assertAlmostEqual(bom.base_raw_material_cost, base_raw_material_cost)
self.assertAlmostEqual(bom.base_total_cost, base_raw_material_cost + base_op_cost)
@timeout
def test_bom_no_operation_time_validation(self):
bom = frappe.copy_doc(test_records[2])
bom.docstatus = 0
for op_row in bom.operations:
op_row.time_in_mins = 0
self.assertRaises(frappe.ValidationError, bom.save)
@timeout
def test_bom_cost_with_batch_size(self):
bom = frappe.copy_doc(test_records[2])