mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 22:49:19 +00:00
fix: Adding validation for operation time in BOM
This commit is contained in:
@@ -1246,6 +1246,12 @@ class BOM(WebsiteGenerator):
|
|||||||
"Row {0}: Workstation or Workstation Type is mandatory for an operation {1}"
|
"Row {0}: Workstation or Workstation Type is mandatory for an operation {1}"
|
||||||
).format(d.idx, d.operation)
|
).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:
|
def get_tree_representation(self) -> BOMTree:
|
||||||
"""Get a complete tree representation preserving order of child items."""
|
"""Get a complete tree representation preserving order of child items."""
|
||||||
|
|||||||
@@ -133,6 +133,15 @@ class TestBOM(ERPNextTestSuite):
|
|||||||
self.assertAlmostEqual(bom.base_raw_material_cost, base_raw_material_cost)
|
self.assertAlmostEqual(bom.base_raw_material_cost, base_raw_material_cost)
|
||||||
self.assertAlmostEqual(bom.base_total_cost, base_raw_material_cost + base_op_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(self.globalTestRecords["BOM"][2])
|
||||||
|
bom.docstatus = 0
|
||||||
|
for op_row in bom.operations:
|
||||||
|
op_row.time_in_mins = 0
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, bom.save)
|
||||||
|
|
||||||
@timeout
|
@timeout
|
||||||
def test_bom_cost_with_batch_size(self):
|
def test_bom_cost_with_batch_size(self):
|
||||||
bom = frappe.copy_doc(self.globalTestRecords["BOM"][2])
|
bom = frappe.copy_doc(self.globalTestRecords["BOM"][2])
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ class TestJobCard(ERPNextTestSuite):
|
|||||||
"workstation": "_Test Workstation 1",
|
"workstation": "_Test Workstation 1",
|
||||||
"bom_no": cut_bom,
|
"bom_no": cut_bom,
|
||||||
"skip_material_transfer": 1,
|
"skip_material_transfer": 1,
|
||||||
|
"time_in_mins": 60,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
final_bom.append(
|
final_bom.append(
|
||||||
@@ -105,6 +106,7 @@ class TestJobCard(ERPNextTestSuite):
|
|||||||
"workstation": "_Test Workstation 1",
|
"workstation": "_Test Workstation 1",
|
||||||
"bom_no": stitch_bom,
|
"bom_no": stitch_bom,
|
||||||
"skip_material_transfer": 1,
|
"skip_material_transfer": 1,
|
||||||
|
"time_in_mins": 60,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
final_bom.append(
|
final_bom.append(
|
||||||
@@ -115,6 +117,7 @@ class TestJobCard(ERPNextTestSuite):
|
|||||||
"bom_no": final_bom.name,
|
"bom_no": final_bom.name,
|
||||||
"is_final_finished_good": 1,
|
"is_final_finished_good": 1,
|
||||||
"skip_material_transfer": 1,
|
"skip_material_transfer": 1,
|
||||||
|
"time_in_mins": 60,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
final_bom.append("items", {"item_code": stitch_fg.name, "qty": 1, "operation_row_id": 3})
|
final_bom.append("items", {"item_code": stitch_fg.name, "qty": 1, "operation_row_id": 3})
|
||||||
@@ -927,6 +930,7 @@ class TestJobCard(ERPNextTestSuite):
|
|||||||
"bom_no": sfg_bom.name,
|
"bom_no": sfg_bom.name,
|
||||||
"finished_good_qty": 1,
|
"finished_good_qty": 1,
|
||||||
"sequence_id": 1,
|
"sequence_id": 1,
|
||||||
|
"time_in_mins": 60,
|
||||||
}
|
}
|
||||||
operation2 = {
|
operation2 = {
|
||||||
"operation": "Test Operation B",
|
"operation": "Test Operation B",
|
||||||
@@ -936,6 +940,7 @@ class TestJobCard(ERPNextTestSuite):
|
|||||||
"finished_good_qty": 1,
|
"finished_good_qty": 1,
|
||||||
"is_final_finished_good": 1,
|
"is_final_finished_good": 1,
|
||||||
"sequence_id": 2,
|
"sequence_id": 2,
|
||||||
|
"time_in_mins": 60,
|
||||||
}
|
}
|
||||||
|
|
||||||
make_workstation(operation1)
|
make_workstation(operation1)
|
||||||
|
|||||||
Reference in New Issue
Block a user