Scheduler added for reminder notification - which will be sent 2 days before the task begins
This commit is contained in:
parent
f2a5c290b3
commit
f1e98b9d8b
@ -1,13 +1,13 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, set_default, str_esc_quote, user_format, validate_email_add, add_days
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
@ -114,3 +114,17 @@ class DocType:
|
||||
else:
|
||||
sql("update `tabProject` set status = 'Completed' where name = %s", arg)
|
||||
return cstr('true')
|
||||
def sent_reminder_task(self):
|
||||
task_list = sql("select subject, allocated_to, project, exp_start_date, exp_end_date, \
|
||||
priority, status, name from tabTicket where email_notify=1 and reminder=0 and status='Open'",as_dict=1)
|
||||
for i in task_list:
|
||||
if (add_days(nowdate(),2) > i['exp_start_date']) and (add_days(nowdate(),3) < i['exp_start_date']):
|
||||
msg2="""This is an auto generated email.<br/><br/>This is a reminder for the task %s has been assigned \
|
||||
to you by %s on %s<br/><br/>Project: %s <br/><br/>Review Date: %s<br/><br/>Closing Date: %s \
|
||||
<br/><br/>Details: %s <br/><br/>""" \
|
||||
%(self.doc.name, self.doc.senders_name, self.doc.opening_date, \
|
||||
self.doc.project, self.doc.review_date, self.doc.closing_date, self.doc.description)
|
||||
sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', msg=msg2,send_now=1,\
|
||||
subject='A task has been assigned')
|
||||
self.doc.sent_reminder=1
|
||||
|
||||
|
@ -76,13 +76,7 @@ class DocType:
|
||||
return
|
||||
else:
|
||||
self.doc.allocated_to_old = self.doc.allocated_to
|
||||
msg2="""This is an auto generated email.<br/>A task %s has been assigned to you by %s on %s<br/><br/>\
|
||||
Project: %s <br/><br/>Review Date: %s<br/><br/>Closing Date: %s <br/><br/>Details: %s <br/><br/>""" \
|
||||
%(self.doc.name, self.doc.senders_name, self.doc.opening_date, \
|
||||
self.doc.project, self.doc.review_date, self.doc.closing_date, self.doc.description)
|
||||
sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', msg=msg2,send_now=1,\
|
||||
subject='A task has been assigned')
|
||||
self.doc.sent_reminder=0
|
||||
self.sent_notification()
|
||||
if self.doc.exp_start_date:
|
||||
sql("delete from tabEvent where ref_type='Task' and ref_name=%s", self.doc.name)
|
||||
self.add_calendar_event()
|
||||
@ -96,6 +90,15 @@ class DocType:
|
||||
msgprint("Please enter allocated_to.")
|
||||
raise Exception
|
||||
self.validate_with_timesheet_dates()
|
||||
#Sent Notification
|
||||
def sent_notification(self):
|
||||
msg2="""This is an auto generated email.<br/>A task %s has been assigned to you by %s on %s<br/><br/>\
|
||||
Project: %s <br/><br/>Review Date: %s<br/><br/>Closing Date: %s <br/><br/>Details: %s <br/><br/>""" \
|
||||
%(self.doc.name, self.doc.senders_name, self.doc.opening_date, \
|
||||
self.doc.project, self.doc.review_date, self.doc.closing_date, self.doc.description)
|
||||
sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', msg=msg2,send_now=1,\
|
||||
subject='A task has been assigned')
|
||||
self.doc.sent_reminder=0
|
||||
|
||||
#validate before closing task
|
||||
def validate_for_closed(self):
|
||||
|
@ -5,14 +5,14 @@
|
||||
{
|
||||
'creation': '2011-01-28 17:52:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-12-22 14:31:07',
|
||||
'modified': '2011-12-23 11:13:42',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1324468340',
|
||||
'_last_update': '1324544468',
|
||||
'allow_trash': 1,
|
||||
'autoname': 'TIC/.####',
|
||||
'colour': 'White:FFF',
|
||||
@ -26,7 +26,7 @@
|
||||
'show_in_menu': 0,
|
||||
'subject': '%(subject)s',
|
||||
'tag_fields': 'status',
|
||||
'version': 250
|
||||
'version': 251
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -290,7 +290,7 @@
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sent_reminder',
|
||||
'fieldtype': 'Date',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'label': 'Sent Reminder',
|
||||
'no_copy': 1,
|
||||
|
Loading…
Reference in New Issue
Block a user