test: cleanup BOM in test_routing and prevent overlap in test_job_card (#25180)
This commit is contained in:
parent
37b826b988
commit
993cf8c2cd
@ -13,8 +13,15 @@ from erpnext.manufacturing.doctype.workstation.test_workstation import make_work
|
|||||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
||||||
|
|
||||||
class TestRouting(unittest.TestCase):
|
class TestRouting(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.item_code = "Test Routing Item - A"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
frappe.db.sql('delete from tabBOM where item=%s', cls.item_code)
|
||||||
|
|
||||||
def test_sequence_id(self):
|
def test_sequence_id(self):
|
||||||
item_code = "Test Routing Item - A"
|
|
||||||
operations = [{"operation": "Test Operation A", "workstation": "Test Workstation A", "time_in_mins": 30},
|
operations = [{"operation": "Test Operation A", "workstation": "Test Workstation A", "time_in_mins": 30},
|
||||||
{"operation": "Test Operation B", "workstation": "Test Workstation A", "time_in_mins": 20}]
|
{"operation": "Test Operation B", "workstation": "Test Workstation A", "time_in_mins": 20}]
|
||||||
|
|
||||||
@ -22,8 +29,8 @@ class TestRouting(unittest.TestCase):
|
|||||||
|
|
||||||
setup_operations(operations)
|
setup_operations(operations)
|
||||||
routing_doc = create_routing(routing_name="Testing Route", operations=operations)
|
routing_doc = create_routing(routing_name="Testing Route", operations=operations)
|
||||||
bom_doc = setup_bom(item_code=item_code, routing=routing_doc.name)
|
bom_doc = setup_bom(item_code=self.item_code, routing=routing_doc.name)
|
||||||
wo_doc = make_wo_order_test_record(production_item = item_code, bom_no=bom_doc.name)
|
wo_doc = make_wo_order_test_record(production_item = self.item_code, bom_no=bom_doc.name)
|
||||||
|
|
||||||
for row in routing_doc.operations:
|
for row in routing_doc.operations:
|
||||||
self.assertEqual(row.sequence_id, row.idx)
|
self.assertEqual(row.sequence_id, row.idx)
|
||||||
|
|||||||
@ -371,14 +371,14 @@ class TestWorkOrder(unittest.TestCase):
|
|||||||
|
|
||||||
def test_job_card(self):
|
def test_job_card(self):
|
||||||
stock_entries = []
|
stock_entries = []
|
||||||
data = frappe.get_cached_value('BOM',
|
bom = frappe.get_doc('BOM', {
|
||||||
{'docstatus': 1, 'with_operations': 1, 'company': '_Test Company'}, ['name', 'item'])
|
'docstatus': 1,
|
||||||
|
'with_operations': 1,
|
||||||
|
'company': '_Test Company'
|
||||||
|
})
|
||||||
|
|
||||||
bom, bom_item = data
|
work_order = make_wo_order_test_record(item=bom.item, qty=1,
|
||||||
|
bom_no=bom.name, source_warehouse="_Test Warehouse - _TC")
|
||||||
bom_doc = frappe.get_doc('BOM', bom)
|
|
||||||
work_order = make_wo_order_test_record(item=bom_item, qty=1,
|
|
||||||
bom_no=bom, source_warehouse="_Test Warehouse - _TC")
|
|
||||||
|
|
||||||
for row in work_order.required_items:
|
for row in work_order.required_items:
|
||||||
stock_entry_doc = test_stock_entry.make_stock_entry(item_code=row.item_code,
|
stock_entry_doc = test_stock_entry.make_stock_entry(item_code=row.item_code,
|
||||||
@ -390,14 +390,14 @@ class TestWorkOrder(unittest.TestCase):
|
|||||||
stock_entries.append(ste)
|
stock_entries.append(ste)
|
||||||
|
|
||||||
job_cards = frappe.get_all('Job Card', filters = {'work_order': work_order.name})
|
job_cards = frappe.get_all('Job Card', filters = {'work_order': work_order.name})
|
||||||
self.assertEqual(len(job_cards), len(bom_doc.operations))
|
self.assertEqual(len(job_cards), len(bom.operations))
|
||||||
|
|
||||||
for i, job_card in enumerate(job_cards):
|
for i, job_card in enumerate(job_cards):
|
||||||
doc = frappe.get_doc("Job Card", job_card)
|
doc = frappe.get_doc("Job Card", job_card)
|
||||||
doc.append("time_logs", {
|
doc.append("time_logs", {
|
||||||
"from_time": now(),
|
"from_time": add_to_date(None, i),
|
||||||
"hours": i,
|
"hours": 1,
|
||||||
"to_time": add_to_date(now(), i),
|
"to_time": add_to_date(None, i + 1),
|
||||||
"completed_qty": doc.for_quantity
|
"completed_qty": doc.for_quantity
|
||||||
})
|
})
|
||||||
doc.submit()
|
doc.submit()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user