Custom fields expiry dates of Licenses

Hi @Frz:

Notification just … notifies :slight_smile:

But automate ToDo is pretty simple.
Create a server script, type “Scheduler Event” with Daily frequency.

customers = frappe.db.sql("""select name, custom_license_expiry_date from `Customer` where DATEDIFF(custom_license_expiry_date,CURRENT_DATE)=7""", as_list=1)

for customer in customers:
        task = frappe.get_doc({
            "doctype": "ToDo",
            "due_date": customer.custom_license_expiry_date,
            "description": "Renew license " + customer.name,
            "reference_type": "Customer",
            "reference_name": customer.name
            })
        task.insert()
    

This way, each day the script create todo taks for renew licenses wich expires in 7 days.
Hope this helps.

2 Likes