scheduler

This commit is contained in:
Nijil Y 2011-12-23 15:08:43 +05:30
parent 4d64379aa6
commit cc0e502d0f
2 changed files with 15 additions and 9 deletions

View File

@ -114,18 +114,23 @@ 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 task_email_notify=1 and sent_reminder=0 and status='Open' and \ def sent_reminder_task():
exp_start_date is not null",as_dict=1) task_list = sql("select subject, allocated_to, project, exp_start_date, exp_end_date, \
for i in task_list: priority, status, name, senders_name, opening_date, review_date, description from tabTicket \
if (add_days(nowdate(),2) > i['exp_start_date']) and (add_days(nowdate(),3) < i['exp_start_date']): where task_email_notify=1 and sent_reminder=0 and status='Open' and \
msg2="""This is an auto generated email.<br/><br/>This is a reminder for the task %s has been assigned \ exp_start_date is not null",as_dict=1)
to you by %s on %s<br/><br/>Project: %s <br/><br/>Review Date: %s<br/><br/>Closing Date: %s \ msgprint(task_list)
<br/><br/>Details: %s <br/><br/>The expected start date of this task is on %s """ \ for i in task_list:
%(self.doc.name, self.doc.senders_name, self.doc.opening_date, \ if date_diff(i['exp_start_date'],nowdate())==2:
self.doc.project, self.doc.review_date, self.doc.closing_date, self.doc.description) msgprint(i['exp_start_date'])
sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', msg=msg2,send_now=1,\ msgprint(add_days(nowdate(),2))
subject='A task has been assigned') msg2="""This is an auto generated email.<br/><br/>This is a reminder for the task %s has been assigned \
self.doc.sent_reminder=1 to you by %s on %s<br/><br/>Project: %s <br/><br/>Review Date: %s \
<br/><br/>Details: %s <br/><br/>The expected start date of this task is on %s """ \
%(i['name'], i['senders_name'], i['opening_date'], i['project'], i['review_date'], i['description'], i['exp_start_date'])
sendmail(i['allocated_to'], sender='automail@webnotestech.com', msg=msg2,send_now=1,\
subject='A task has been assigned')
i['sent_reminder']=1

View File

@ -175,7 +175,7 @@ class DocType:
set(self.doc, 'docstatus', 1) set(self.doc, 'docstatus', 1)
self.doc.save() self.doc.save()
return cstr('true') return cstr('true')
def remove_event_from_calender(): def remove_event_from_calender(self):
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.doc.save() self.doc.save()
def cancel_task(self): def cancel_task(self):
@ -187,6 +187,7 @@ class DocType:
else: else:
set(self.doc, 'status', 'Cancelled') set(self.doc, 'status', 'Cancelled')
set(self.doc, 'docstatus', 2) set(self.doc, 'docstatus', 2)
self.remove_event_from_calender()
self.doc.save() self.doc.save()
return cstr('true') return cstr('true')