as we know that the Project - Tasks
Task has a status like open - close so on
and one of its status to be Overdue
Offcourse the system is making the task in Overdue state
if Expected End Date has come without any action
I mad a new Doctype nmae Feed
with Tow Custome fields
enddate ---- Type Date status — Type Select ( open - close - working on - overdue )
Lets Take an example
If enddate = 17-3-2018
and Today is > 17-3-2018
So the script change the status filed automatically to be overdue
same manner of project - task mechanism .
Below method will update the status as you’r willing for but only when someone changes end_date field, not automatically. you can call this function on any change you feels better.
Hopes someone will tell you a method for changing the status automatically like tasks,
Make “Status” field with datatype “Select” option “Open , Close , Working , Overdue” in “Feed”
and use this script.
frappe.ui.form.on(“Feed”,
{
end_date: function(frm){
change_status(frm);
}
});
var change_status = function(frm)
{
var today = frappe.datetime.get_today();
Ok then it works like this:
1.Create in your doctype folder a file called feed.py
2.Add in feed.py file a function like this:
def set_feed_as_overdue():
frappe.db.sql("""update tabFeed set `status`='Overdue'
where exp_end_date is not null
and exp_end_date < CURDATE()
and `status` not in ('Closed', 'Cancelled')""")
3.Add following in hooks.py of ERPNext in "scheduler_events = {…“daily”: [… "erpnext.[your module].doctype.feed.feed.set_feed_as_overdue"
Now it will check every day if one or more of youre feeds is overdue and if so it will set status overdue to it/them.
Can we use this method with a little of modification in another scenario
For example
Healthcare module , there is a patient appointment doctype
lets say
patient A booked a ppointment after month from now
can we send him an email to remind him with one week befor his appointment
with same methodology
we will let mysql check the date every day and if it founds the ( todaydate +7)=appointment date
so it will send an email to the client to remind him that his appointment will be during week .
This is even easier without any customizations!
There is a standard feature in ERPNext called “Email Alert”.
You can perfectly cover this use case with it.