mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-29 09:01:14 +02:00
fix: validate duplicate serial no on submit in DN (#37243)
This commit is contained in:
@@ -138,7 +138,9 @@ class DeliveryNote(SellingController):
|
|||||||
self.validate_uom_is_integer("stock_uom", "stock_qty")
|
self.validate_uom_is_integer("stock_uom", "stock_qty")
|
||||||
self.validate_uom_is_integer("uom", "qty")
|
self.validate_uom_is_integer("uom", "qty")
|
||||||
self.validate_with_previous_doc()
|
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
|
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
|
||||||
|
|
||||||
|
|||||||
@@ -1234,14 +1234,10 @@ class TestDeliveryNote(FrappeTestCase):
|
|||||||
)
|
)
|
||||||
dn.items[0].serial_no = "\n".join(serial_nos[:2])
|
dn.items[0].serial_no = "\n".join(serial_nos[:2])
|
||||||
dn.append("items", dn.items[0].as_dict())
|
dn.append("items", dn.items[0].as_dict())
|
||||||
|
dn.save()
|
||||||
|
|
||||||
# Test - 1: ValidationError should be raised
|
# Test - 1: ValidationError should be raised
|
||||||
self.assertRaises(frappe.ValidationError, dn.save)
|
self.assertRaises(frappe.ValidationError, dn.submit)
|
||||||
|
|
||||||
# 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):
|
def tearDown(self):
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
|
|||||||
Reference in New Issue
Block a user