From cc0e502d0faf2467d622203a179c0acbb47dcaab Mon Sep 17 00:00:00 2001 From: Nijil Y Date: Fri, 23 Dec 2011 15:08:43 +0530 Subject: [PATCH] scheduler --- .../project_control/project_control.py | 21 ++++++++++++------- erpnext/projects/doctype/ticket/ticket.py | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/erpnext/projects/doctype/project_control/project_control.py b/erpnext/projects/doctype/project_control/project_control.py index 4d74e8c182..92ed64b389 100644 --- a/erpnext/projects/doctype/project_control/project_control.py +++ b/erpnext/projects/doctype/project_control/project_control.py @@ -114,18 +114,23 @@ class DocType: else: sql("update `tabProject` set status = 'Completed' where name = %s", arg) return cstr('true') -def sent_reminder_task(self): + + +def sent_reminder_task(): 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 \ + priority, status, name, senders_name, opening_date, review_date, description from tabTicket \ + where task_email_notify=1 and sent_reminder=0 and status='Open' and \ exp_start_date is not null",as_dict=1) + msgprint(task_list) for i in task_list: - if (add_days(nowdate(),2) > i['exp_start_date']) and (add_days(nowdate(),3) < i['exp_start_date']): + if date_diff(i['exp_start_date'],nowdate())==2: + msgprint(i['exp_start_date']) + msgprint(add_days(nowdate(),2)) msg2="""This is an auto generated email.

This is a reminder for the task %s has been assigned \ - to you by %s on %s

Project: %s

Review Date: %s

Closing Date: %s \ + to you by %s on %s

Project: %s

Review Date: %s \

Details: %s

The expected start date of this task is on %s """ \ - %(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,\ + %(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') - self.doc.sent_reminder=1 + i['sent_reminder']=1 diff --git a/erpnext/projects/doctype/ticket/ticket.py b/erpnext/projects/doctype/ticket/ticket.py index 1868eeb93d..a378194aed 100644 --- a/erpnext/projects/doctype/ticket/ticket.py +++ b/erpnext/projects/doctype/ticket/ticket.py @@ -175,7 +175,7 @@ class DocType: set(self.doc, 'docstatus', 1) self.doc.save() 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) self.doc.save() def cancel_task(self): @@ -187,6 +187,7 @@ class DocType: else: set(self.doc, 'status', 'Cancelled') set(self.doc, 'docstatus', 2) + self.remove_event_from_calender() self.doc.save() return cstr('true')