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
|
# Please edit this list and import only required elements
|
||||||
import webnotes
|
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 import db_exists
|
||||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||||
from webnotes.model.doclist import getlist, copy_doclist
|
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.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 import session, form, is_testing, msgprint, errprint
|
||||||
|
from webnotes.utils.email_lib import sendmail
|
||||||
set = webnotes.conn.set
|
set = webnotes.conn.set
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
get_value = webnotes.conn.get_value
|
get_value = webnotes.conn.get_value
|
||||||
@ -114,3 +114,17 @@ class DocType:
|
|||||||
else:
|
else:
|
||||||
sql("update `tabProject` set status = 'Completed' where name = %s", arg)
|
sql("update `tabProject` set status = 'Completed' where name = %s", arg)
|
||||||
return cstr('true')
|
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
|
return
|
||||||
else:
|
else:
|
||||||
self.doc.allocated_to_old = self.doc.allocated_to
|
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/>\
|
self.sent_notification()
|
||||||
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
|
|
||||||
if self.doc.exp_start_date:
|
if self.doc.exp_start_date:
|
||||||
sql("delete from tabEvent where ref_type='Task' and ref_name=%s", self.doc.name)
|
sql("delete from tabEvent where ref_type='Task' and ref_name=%s", self.doc.name)
|
||||||
self.add_calendar_event()
|
self.add_calendar_event()
|
||||||
@ -96,6 +90,15 @@ class DocType:
|
|||||||
msgprint("Please enter allocated_to.")
|
msgprint("Please enter allocated_to.")
|
||||||
raise Exception
|
raise Exception
|
||||||
self.validate_with_timesheet_dates()
|
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
|
#validate before closing task
|
||||||
def validate_for_closed(self):
|
def validate_for_closed(self):
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
{
|
{
|
||||||
'creation': '2011-01-28 17:52:35',
|
'creation': '2011-01-28 17:52:35',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2011-12-22 14:31:07',
|
'modified': '2011-12-23 11:13:42',
|
||||||
'modified_by': 'Administrator',
|
'modified_by': 'Administrator',
|
||||||
'owner': 'Administrator'
|
'owner': 'Administrator'
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocType
|
# These values are common for all DocType
|
||||||
{
|
{
|
||||||
'_last_update': '1324468340',
|
'_last_update': '1324544468',
|
||||||
'allow_trash': 1,
|
'allow_trash': 1,
|
||||||
'autoname': 'TIC/.####',
|
'autoname': 'TIC/.####',
|
||||||
'colour': 'White:FFF',
|
'colour': 'White:FFF',
|
||||||
@ -26,7 +26,7 @@
|
|||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'subject': '%(subject)s',
|
'subject': '%(subject)s',
|
||||||
'tag_fields': 'status',
|
'tag_fields': 'status',
|
||||||
'version': 250
|
'version': 251
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@ -290,7 +290,7 @@
|
|||||||
{
|
{
|
||||||
'doctype': 'DocField',
|
'doctype': 'DocField',
|
||||||
'fieldname': 'sent_reminder',
|
'fieldname': 'sent_reminder',
|
||||||
'fieldtype': 'Date',
|
'fieldtype': 'Data',
|
||||||
'hidden': 1,
|
'hidden': 1,
|
||||||
'label': 'Sent Reminder',
|
'label': 'Sent Reminder',
|
||||||
'no_copy': 1,
|
'no_copy': 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user