Skip to content

Commit

Permalink
fix: validate duplicate serial no on submit in DN (#37243)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r authored Sep 26, 2023
1 parent 279f21d commit 70e2093
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion erpnext/stock/doctype/delivery_note/delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def validate(self):
self.validate_uom_is_integer("stock_uom", "stock_qty")
self.validate_uom_is_integer("uom", "qty")
self.validate_with_previous_doc()
self.validate_duplicate_serial_nos()

if self.get("_action") == "submit":
self.validate_duplicate_serial_nos()

from erpnext.stock.doctype.packed_item.packed_item import make_packing_list

Expand Down
8 changes: 2 additions & 6 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,14 +1234,10 @@ def test_duplicate_serial_no_in_delivery_note(self):
)
dn.items[0].serial_no = "\n".join(serial_nos[:2])
dn.append("items", dn.items[0].as_dict())
dn.save()

# 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()
self.assertRaises(frappe.ValidationError, dn.submit)

def tearDown(self):
frappe.db.rollback()
Expand Down

0 comments on commit 70e2093

Please sign in to comment.