mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 15:38:39 +00:00
test: duplicate manufacture entry against a work order
A second Manufacture stock entry saved while existing entries already cover the full work order qty must raise DuplicateEntryForWorkOrderError.
This commit is contained in:
@@ -28,6 +28,7 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle
|
||||
)
|
||||
from erpnext.stock.doctype.serial_no.serial_no import *
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry import (
|
||||
DuplicateEntryForWorkOrderError,
|
||||
FinishedGoodError,
|
||||
get_pending_work_orders,
|
||||
make_stock_in_entry,
|
||||
@@ -1272,6 +1273,30 @@ class TestStockEntry(ERPNextTestSuite):
|
||||
se_ok.submit()
|
||||
self.assertEqual(se_ok.docstatus, 1)
|
||||
|
||||
def test_duplicate_entry_for_work_order(self):
|
||||
from erpnext.manufacturing.doctype.work_order.mapper import (
|
||||
make_stock_entry as make_wo_stock_entry,
|
||||
)
|
||||
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
|
||||
|
||||
wo = make_wo_order_test_record(qty=1)
|
||||
make_stock_entry(item_code="_Test Item", target="Stores - _TC", qty=10, basic_rate=100)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100", target="Stores - _TC", qty=10, basic_rate=100
|
||||
)
|
||||
|
||||
transfer = frappe.get_doc(make_wo_stock_entry(wo.name, "Material Transfer for Manufacture", 1))
|
||||
for d in transfer.get("items"):
|
||||
d.s_warehouse = "Stores - _TC"
|
||||
transfer.insert()
|
||||
transfer.submit()
|
||||
|
||||
mfg = frappe.get_doc(make_wo_stock_entry(wo.name, "Manufacture", 1))
|
||||
mfg.insert()
|
||||
|
||||
duplicate = frappe.get_doc(make_wo_stock_entry(wo.name, "Manufacture", 1))
|
||||
self.assertRaises(DuplicateEntryForWorkOrderError, duplicate.insert)
|
||||
|
||||
@ERPNextTestSuite.change_settings("Stock Settings", {"action_if_quality_inspection_is_rejected": "Stop"})
|
||||
def test_quality_inspection_required_for_manufacture(self):
|
||||
from erpnext.exceptions import QualityInspectionRejectedError, QualityInspectionRequiredError
|
||||
|
||||
Reference in New Issue
Block a user