Skip to content

Commit

Permalink
test: add test case for DN duplicate serial nos
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Sep 15, 2023
1 parent fffa13f commit e5177a6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,38 @@ def test_batch_expiry_for_delivery_note(self):

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)
Expand Down

0 comments on commit e5177a6

Please sign in to comment.