Update erpnext/projects/doctype/ticket/ticket.py

This commit is contained in:
Nijil Y
2011-12-23 16:18:49 +05:30
parent cc0e502d0f
commit 9239afa222

View File

@@ -71,25 +71,23 @@ class DocType:
def on_update(self): def on_update(self):
if self.doc.status =='Open' and self.doc.allocated_to: if self.doc.status =='Open' and self.doc.allocated_to:
if self.doc.task_email_notify==1: if self.doc.task_email_notify and (self.doc.allocated_to != self.doc.allocated_to_old):
if (self.doc.allocated_to == self.doc.allocated_to_old): self.doc.allocated_to_old = self.doc.allocated_to
return self.sent_notification()
else:
self.doc.allocated_to_old = self.doc.allocated_to
self.sent_notification()
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()
else: else:
msgprint("An Expeted start date has not been set for this task.Please set a, 'Expected Start date'\ msgprint("An Expeted start date has not been set for this task.Please set a, 'Expected Start date'\
to add an event to allocated persons calender.You can save a task without this also.") to add an event to allocated persons calender.You can save a task without this also.")
pass
def validate_for_pending_review(self): def validate_for_pending_review(self):
if not self.doc.allocated_to: if not self.doc.allocated_to:
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 #Sent Notification
def sent_notification(self): 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/>\ msg2="""This is an auto generated email.<br/>A task %s has been assigned to you by %s on %s<br/><br/>\
@@ -175,9 +173,11 @@ 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(self): 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):
chk = sql("select distinct t1.name from `tabTimesheet` t1, `tabTimesheet Detail` t2 where t2.parent = t1.name and t2.task_id = %s and t1.status!='Cancelled'", self.doc.name) chk = sql("select distinct t1.name from `tabTimesheet` t1, `tabTimesheet Detail` t2 where t2.parent = t1.name and t2.task_id = %s and t1.status!='Cancelled'", self.doc.name)
if chk: if chk:
@@ -185,20 +185,19 @@ class DocType:
msgprint("Timesheet(s) "+','.join(chk_lst)+" created against this task. Thus can not be cancelled") msgprint("Timesheet(s) "+','.join(chk_lst)+" created against this task. Thus can not be cancelled")
raise Exception raise Exception
else: else:
set(self.doc, 'status', 'Cancelled') self.doc.status = 'Cancelled'
set(self.doc, 'docstatus', 2) self.doc.docstatus = 2
self.remove_event_from_calender() self.remove_event_from_calender()
self.doc.save() self.doc.save()
return cstr('true') return cstr('true')
def add_calendar_event(self): def add_calendar_event(self):
in_calendar_of = self.doc.allocated_to
event = Document('Event') event = Document('Event')
event.owner = in_calendar_of event.owner = self.doc.allocated_to
event.description ='' event.description =''
event.event_date = self.doc.exp_start_date and self.doc.exp_start_date or '' event.event_date = self.doc.exp_start_date and self.doc.exp_start_date or ''
event.event_hour = '10:00' event.event_hour = self.doc.event_hour and self.doc.event_hour or '10:00'
event.event_type = 'Private' event.event_type = 'Private'
event.ref_type = 'Task' event.ref_type = 'Task'
event.ref_name = self.doc.name event.ref_name = self.doc.name