fix: validate duplicate serial no on submit in DN (#37243)

This commit is contained in:
s-aga-r
2023-09-26 16:34:19 +05:30
committed by GitHub
parent 279f21d1e5
commit 70e2093941
2 changed files with 5 additions and 7 deletions

View File

@@ -138,7 +138,9 @@ class DeliveryNote(SellingController):
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

View File

@@ -1234,14 +1234,10 @@ class TestDeliveryNote(FrappeTestCase):
)
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()