commit
40deced91c
@ -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,29 @@ class DocType:
|
||||
else:
|
||||
sql("update `tabProject` set status = 'Completed' where name = %s", arg)
|
||||
return cstr('true')
|
||||
|
||||
|
||||
def sent_reminder_task():
|
||||
task_list = sql("""
|
||||
select subject, allocated_to, project, exp_start_date, exp_end_date,
|
||||
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)
|
||||
for i in task_list:
|
||||
if date_diff(i['exp_start_date'],nowdate()) ==2:
|
||||
msg2="""<h2>Two days to complete: %(name)s</h2>
|
||||
<p>This is a reminder for the task %(name)s has been assigned to you
|
||||
by %(senders_name)s on %(opening_date)s</p>
|
||||
<p><b>Project:</b> %(project)s</p>
|
||||
<p><b>Review Date:</b> %(review_date)s</p>
|
||||
<p><b>Details:</b> %(description)s</p>
|
||||
<p>If you have already completed this task, please update the system</p>
|
||||
<p>Good Luck!</p>
|
||||
<p>(This notification is autogenerated)</p>""" % i
|
||||
sendmail(i['allocated_to'], sender='automail@webnotestech.com', msg=msg2,send_now=1, \
|
||||
subject='A task has been assigned')
|
||||
sql("update `tabTicket` set sent_reminder='1' where name='%(name)s' and allocated_to= '%(allocated_to)s'" % i)
|
||||
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
# 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
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
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
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
set = webnotes.conn.set
|
||||
get_value = webnotes.conn.get_value
|
||||
@ -68,22 +70,41 @@ class DocType:
|
||||
#--------------------------------------------
|
||||
|
||||
def on_update(self):
|
||||
if (self.doc.status =='Open') and (self.doc.task_email_notify==1):
|
||||
msg2= 'A task %s has been assigned to you by %s on %s <br/> \
|
||||
Project:%s <br/> Review Date:%s <br /> Closing Date:%s <br /> Details %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', \
|
||||
subject='A task has been assigned', parts=[['text/plain',msg2]])
|
||||
pass
|
||||
if self.doc.status =='Open' and self.doc.allocated_to:
|
||||
if self.doc.task_email_notify and (self.doc.allocated_to != self.doc.allocated_to_old):
|
||||
self.doc.sent_reminder = 0
|
||||
self.doc.allocated_to_old = self.doc.allocated_to
|
||||
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()
|
||||
else:
|
||||
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.")
|
||||
|
||||
|
||||
#validate before sending for approval
|
||||
def validate_for_pending_review(self):
|
||||
if not self.doc.allocated_to:
|
||||
msgprint("Please enter allocated_to.")
|
||||
raise Exception
|
||||
self.validate_with_timesheet_dates()
|
||||
|
||||
#Sent Notification
|
||||
def sent_notification(self):
|
||||
msg2="""<h2>%(name)s</h2>
|
||||
<p>This is a Notification for the task %(name)s that has been assigned to you
|
||||
by %(senders_name)s on %(opening_date)s</p>
|
||||
<p><b>Project:</b> %(project)s</p>
|
||||
<p><b>Review Date:</b> %(review_date)s</p>
|
||||
<p><b>Details:</b> %(description)s</p>
|
||||
<p>You will also recieve another reminder 2 days before the commencement of the task</p>
|
||||
<p>Good Luck!</p>
|
||||
<p>(This notification is autogenerated)</p>""" % i
|
||||
sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', msg=msg2,send_now=1,\
|
||||
subject='A task has been assigned')
|
||||
|
||||
|
||||
|
||||
#validate before closing task
|
||||
def validate_for_closed(self):
|
||||
self.check_non_submitted_timesheets()
|
||||
@ -137,12 +158,12 @@ class DocType:
|
||||
self.validate_for_pending_review()
|
||||
self.get_actual_total_hrs()
|
||||
self.doc.review_date = nowdate()
|
||||
set(self.doc, 'status', 'Pending Review')
|
||||
self.doc.status = 'Pending Review'
|
||||
self.doc.save()
|
||||
return cstr('true')
|
||||
|
||||
def reopen_task(self):
|
||||
set(self.doc, 'status', 'Open')
|
||||
self.doc.status = 'Open'
|
||||
self.doc.save()
|
||||
return cstr('true')
|
||||
|
||||
@ -154,11 +175,16 @@ class DocType:
|
||||
self.validate_with_timesheet_dates()
|
||||
self.validate_for_closed()
|
||||
self.doc.closing_date = nowdate()
|
||||
set(self.doc, 'status', 'Closed')
|
||||
set(self.doc, 'docstatus', 1)
|
||||
self.doc.status = 'Closed'
|
||||
self.remove_event_from_calender()
|
||||
self.doc.docstatus = 1
|
||||
self.doc.save()
|
||||
return cstr('true')
|
||||
|
||||
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):
|
||||
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:
|
||||
@ -166,10 +192,21 @@ class DocType:
|
||||
msgprint("Timesheet(s) "+','.join(chk_lst)+" created against this task. Thus can not be cancelled")
|
||||
raise Exception
|
||||
else:
|
||||
set(self.doc, 'status', 'Cancelled')
|
||||
set(self.doc, 'docstatus', 2)
|
||||
self.doc.status = 'Cancelled'
|
||||
self.doc.docstatus = 2
|
||||
self.remove_event_from_calender()
|
||||
self.doc.save()
|
||||
return cstr('true')
|
||||
|
||||
def on_cancel(self):
|
||||
self.cancel_task()
|
||||
|
||||
def add_calendar_event(self):
|
||||
event = Document('Event')
|
||||
event.owner = self.doc.allocated_to
|
||||
event.description =''
|
||||
event.event_date = self.doc.exp_start_date and self.doc.exp_start_date or ''
|
||||
event.event_hour = self.doc.event_hour and self.doc.event_hour or '10:00'
|
||||
event.event_type = 'Private'
|
||||
event.ref_type = 'Task'
|
||||
event.ref_name = self.doc.name
|
||||
event.save(1)
|
||||
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
{
|
||||
'creation': '2011-01-28 17:52:35',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-12-21 16:32:30',
|
||||
'modified': '2011-12-23 12:02:29',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1324394580',
|
||||
'_last_update': '1324619022',
|
||||
'allow_trash': 1,
|
||||
'autoname': 'TIC/.####',
|
||||
'colour': 'White:FFF',
|
||||
@ -26,7 +26,7 @@
|
||||
'show_in_menu': 0,
|
||||
'subject': '%(subject)s',
|
||||
'tag_fields': 'status',
|
||||
'version': 247
|
||||
'version': 252
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -249,6 +249,17 @@
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'allocated_to_old',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': 1,
|
||||
'label': 'Allocated To Old',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
@ -275,6 +286,17 @@
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sent_reminder',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'label': 'Sent Reminder',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user