Frappe Cloud - Delete all stock items (27,000)


I’m new to ERPNext and tried to search for the same scenario on the forum before posting this question:

My ERPNext is hosted on Frappe cloud and I need to delete about 27,000 stock item records at once. Currently, selecting more than 500 items times out (up to 500 is ok but is taking at least 10 minutes)and further, I have to make a permanent deletion after the fact; this making this process overly time-consuming.

My question, without accessing the bench, and ensuring that any mass-deletion does not delete impact any custom doctypes and fields that I have made, how can I delete all these stock items at once?



1 Like

Hi @ikbenben1976,

This is a bit of a tricky one because the safe execution API doesn’t expose any delete methods to Server Scripts or the System Console.

The easiest way to automate the process might be just to loop through all the items and delete them with some javascript. It wouldn’t be any faster, but it would probably require less intervention on your part.

Something like…

//untested code
frappe.db.get_list("Academic Term").then( 
    list => list.forEach(
        item => frappe.db.delete_doc("Academic Term", 
1 Like

I have done this process.
You need to use Frappe Client, or access the DB directly.
GitHub - frappe/frappe-client: Python library to use Frappe API , It will be slow, but will get the job done.
Anything else may not work.

1 Like