This script enables the system to add an expiry date to sales orders.
To use this script, first create a custom date field in the Sales Order called Valid Till (valid_till)
Create a Server Script
- Select Script Type as Scheduler Event
- Select Event Frequency as per your requirement
yesterday_date = frappe.utils.add_days(frappe.utils.today(), -1)
auto = frappe.get_all("Sales Order",{'valid_till':yesterday_date, 'status': ['not in',['Closed']]})
for i in auto:
so = frappe.get_doc("Sales Order", i.name)
so.update_status("Closed")
Last updated 2 months ago
Was this helpful?