Cancel Multiple Documents at one time

Hi,

We have performed a set of Delivery Note wrongly. Is it possible to Cancel this list of Delivery Notes from the backend?

We have tried the following options but does not seem to work, any other options?

Option 1 :

doc = frappe.get_doc(delivery_note.doctype, delivery_note.name)
doc.cancel()

Option 2:

doc = frappe.get_doc(delivery_note.doctype, delivery_note.name)
doc.docstatus = 2
doc.save()

Option 3:

reverse_dn = frappe.db.sql("""UPDATE `tabDelivery Note` 
  SET docstatus=2 WHERE name=%s""",
  (delivery_note.name))

https://discuss.erpnext.com/t/bulk-deletion-of-submitted-entries/2867