Delete record data on doctype

Hello all,
I’m stuck trying to solve my case, which is I want to delete all the records in the doctype.

frappe.get_doc(dict(
        doctype = 'AAM_QA_DMS_MASTER_ITEM'
    )).delete();
cur_frm.clear_table("AAM_QA_DMS_MASTER_ITEM")
cur_frm.refresh_fields();

all those not working. Pease help. Thankyou

you can write SQL query using

DELETE FROM table_name WHERE condition;

from bench mariadb

Thankyou for your response, but i want todo in custom script.

frappe.db.delete_doc('doctypename',"SMD"); 

SMD is value of name.

thats my script delete for filter,
What if i want to delete all of them?

This will attempt to delete all documents of type DOCTYPE on your server:

doclist = frappe.db.get_all("DOCTYPE")
for doc in doclist:
    frappe.db.delete("DOCTYPE", doc.name)

@joeK try this

frappe.db.sql(""" TRUNCATE TABLE `tabSales Invoice` """)
1 Like

Thank you for your help guys :pray: