Hi All
How to auto-delete data inside doctype after certain timeline.
Hi All
How to auto-delete data inside doctype after certain timeline.
import frappe
from frappe.model.document import Document
class CustomDoctype(Document):
@staticmethod
def clear_old_logs(days=None):
days = days or 30
from frappe.query_builder import Interval
from frappe.query_builder.functions import Now
table = frappe.qb.DocType("CustomDoctype")
frappe.db.delete(
table,
filters=(
(table.modified < (Now() - Interval(days=days))) &
(table.status == "Completed")
)
)
Steps:
For Reference check this Logging
add clear_old_logs function in your .py file and migrate, then check whether your custom doctype is coming here or not
It’s working, Thanks a lot.