mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-20 09:56:31 +00:00
test: add test case for DN duplicate serial nos
This commit is contained in:
@@ -1211,6 +1211,38 @@ class TestDeliveryNote(FrappeTestCase):
|
||||
|
||||
self.assertTrue(return_dn.docstatus == 1)
|
||||
|
||||
def test_duplicate_serial_no_in_delivery_note(self):
|
||||
# Step - 1: Create Serial Item
|
||||
serial_item = make_item(
|
||||
properties={
|
||||
"is_stock_item": 1,
|
||||
"has_serial_no": 1,
|
||||
"serial_no_series": frappe.generate_hash("", 10) + ".###",
|
||||
}
|
||||
).name
|
||||
|
||||
# Step - 2: Inward Stock
|
||||
se = make_stock_entry(item_code=serial_item, target="_Test Warehouse - _TC", qty=4)
|
||||
|
||||
# Step - 3: Create Delivery Note with Duplicare Serial Nos
|
||||
serial_nos = se.items[0].serial_no.split("\n")
|
||||
dn = create_delivery_note(
|
||||
item_code=serial_item,
|
||||
warehouse="_Test Warehouse - _TC",
|
||||
qty=2,
|
||||
do_not_save=True,
|
||||
)
|
||||
dn.items[0].serial_no = "\n".join(serial_nos[:2])
|
||||
dn.append("items", dn.items[0].as_dict())
|
||||
|
||||
# Test - 1: ValidationError should be raised
|
||||
self.assertRaises(frappe.ValidationError, dn.save)
|
||||
|
||||
# Step - 4: Submit Delivery Note with unique Serial Nos
|
||||
dn.items[1].serial_no = "\n".join(serial_nos[2:])
|
||||
dn.save()
|
||||
dn.submit()
|
||||
|
||||
def tearDown(self):
|
||||
frappe.db.rollback()
|
||||
frappe.db.set_single_value("Selling Settings", "dont_reserve_sales_order_qty_on_sales_return", 0)
|
||||
|
||||
Reference in New Issue
Block a user