Email Notification for Tasks

This commit is contained in:
Nijil Y 2011-12-20 21:13:58 +05:30
parent 04da8741c3
commit dc0461296d
2 changed files with 33 additions and 60 deletions

View File

@ -7,9 +7,9 @@ from webnotes.model.doc import Document, addchild, removechild, getchildren, mak
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
# -----------------------------------------------------------------------------------------
@ -31,7 +31,7 @@ class DocType:
return ret
def get_allocated_to_name(self):
as_em = sql("select first_name, last_name from `tabProfile` where name=%s",self.doc.allocated_to)
as_em = sql("select first_name, last_name from `tabProfile` where name=%s",str(self.doc.allocated_to))
ret = { 'allocated_to_name' : as_em and (as_em[0][0] + ' ' + as_em[0][1]) or ''}
return ret
@ -67,6 +67,12 @@ 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 \n%s Project:%s \t Review Date:%s\nClosing Date:%s Details \n %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
#validate before sending for approval

View File

@ -5,17 +5,18 @@
{
'creation': '2011-01-28 17:52:35',
'docstatus': 0,
'modified': '2010-12-03 10:04:58',
'modified': '2011-12-20 20:52:58',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1307707462',
'_last_update': '1323333040',
'allow_trash': 1,
'autoname': 'TIC/.####',
'colour': 'White:FFF',
'default_print_format': 'Standard',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Projects',
@ -25,7 +26,7 @@
'show_in_menu': 0,
'subject': '%(subject)s',
'tag_fields': 'status',
'version': 245
'version': 246
},
# These values are common for all DocField
@ -39,12 +40,17 @@
# These values are common for all DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Ticket',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
'read': 1,
'submit': 1,
'write': 1
},
# DocType, Ticket
@ -55,41 +61,28 @@
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 0,
'role': 'All',
'write': 1
'role': 'All'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 1,
'role': 'All',
'write': 0
'role': 'All'
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 0,
'role': 'Projects User',
'write': 1
'role': 'Projects User'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 1,
'role': 'Projects User'
},
@ -98,7 +91,6 @@
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Task Details',
'oldfieldtype': 'Section Break',
'permlevel': 0,
@ -111,7 +103,6 @@
'doctype': 'DocField',
'fieldname': 'subject',
'fieldtype': 'Data',
'idx': 2,
'in_filter': 1,
'label': 'Subject',
'oldfieldname': 'subject',
@ -125,8 +116,8 @@
'doctype': 'DocField',
'fieldname': 'status',
'fieldtype': 'Select',
'idx': 3,
'label': 'Status',
'no_copy': 1,
'oldfieldname': 'status',
'oldfieldtype': 'Select',
'options': 'Open\nPending Review\nClosed\nCancelled',
@ -134,12 +125,20 @@
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'task_email_notify',
'fieldtype': 'Check',
'label': 'Sent Mail Notification',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'opening_date',
'fieldtype': 'Date',
'idx': 4,
'label': 'Creation Date',
'oldfieldname': 'opening_date',
'oldfieldtype': 'Date',
@ -155,7 +154,6 @@
'fieldname': 'review_date',
'fieldtype': 'Date',
'hidden': 1,
'idx': 5,
'label': 'Review Date',
'oldfieldname': 'review_date',
'oldfieldtype': 'Date',
@ -170,7 +168,6 @@
'fieldname': 'closing_date',
'fieldtype': 'Date',
'hidden': 1,
'idx': 6,
'label': 'Closing Date',
'oldfieldname': 'closing_date',
'oldfieldtype': 'Date',
@ -182,7 +179,6 @@
'doctype': 'DocField',
'fieldname': 'priority',
'fieldtype': 'Select',
'idx': 7,
'in_filter': 1,
'label': 'Priority',
'oldfieldname': 'priority',
@ -199,7 +195,6 @@
'doctype': 'DocField',
'fieldname': 'project',
'fieldtype': 'Link',
'idx': 8,
'label': 'Project',
'oldfieldname': 'project',
'oldfieldtype': 'Link',
@ -214,7 +209,6 @@
'doctype': 'DocField',
'fieldname': 'customer',
'fieldtype': 'Link',
'idx': 9,
'label': 'Customer',
'oldfieldname': 'customer',
'oldfieldtype': 'Link',
@ -228,7 +222,6 @@
'doctype': 'DocField',
'fieldname': 'customer_name',
'fieldtype': 'Data',
'idx': 10,
'label': 'Customer Name',
'oldfieldname': 'customer_name',
'oldfieldtype': 'Data',
@ -239,7 +232,6 @@
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 11,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
@ -251,7 +243,6 @@
'doctype': 'DocField',
'fieldname': 'allocated_to',
'fieldtype': 'Link',
'idx': 12,
'label': 'Allocated To',
'oldfieldname': 'allocated_to',
'oldfieldtype': 'Link',
@ -266,7 +257,6 @@
'fieldname': 'allocated_to_name',
'fieldtype': 'Data',
'hidden': 1,
'idx': 13,
'label': 'Allocated To Name',
'oldfieldname': 'allocated_to_name',
'oldfieldtype': 'Data',
@ -278,7 +268,6 @@
'doctype': 'DocField',
'fieldname': 'senders_name',
'fieldtype': 'Data',
'idx': 14,
'in_filter': 1,
'label': 'Raised By',
'oldfieldname': 'senders_name',
@ -293,7 +282,6 @@
'doctype': 'DocField',
'fieldname': 'senders_email',
'fieldtype': 'Data',
'idx': 15,
'label': 'Email',
'oldfieldname': 'senders_email',
'oldfieldtype': 'Data',
@ -306,7 +294,6 @@
'doctype': 'DocField',
'fieldname': 'senders_contact_no',
'fieldtype': 'Data',
'idx': 16,
'label': 'Senders Contact No',
'oldfieldname': 'senders_contact_no',
'oldfieldtype': 'Data',
@ -318,7 +305,6 @@
'doctype': 'DocField',
'fieldname': 'senders_company',
'fieldtype': 'Data',
'idx': 17,
'label': 'Senders Company',
'oldfieldname': 'senders_company',
'oldfieldtype': 'Data',
@ -330,7 +316,6 @@
'doctype': 'DocField',
'fieldname': 'category',
'fieldtype': 'Link',
'idx': 18,
'label': 'Category',
'oldfieldname': 'category',
'oldfieldtype': 'Link',
@ -343,7 +328,6 @@
'doctype': 'DocField',
'fieldname': 'external_or_internal',
'fieldtype': 'Select',
'idx': 19,
'label': 'External or Internal',
'oldfieldname': 'external_or_internal',
'oldfieldtype': 'Select',
@ -357,7 +341,6 @@
'fieldname': 'amended_from',
'fieldtype': 'Data',
'hidden': 1,
'idx': 20,
'label': 'Amended From',
'no_copy': 1,
'oldfieldname': 'amended_from',
@ -373,7 +356,6 @@
'fieldname': 'amendment_date',
'fieldtype': 'Date',
'hidden': 1,
'idx': 21,
'label': 'Amendment Date',
'no_copy': 1,
'oldfieldname': 'amendment_date',
@ -387,7 +369,6 @@
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 22,
'oldfieldtype': 'Section Break',
'options': 'Simple',
'permlevel': 0
@ -398,7 +379,6 @@
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Text Editor',
'idx': 23,
'label': 'Details',
'oldfieldname': 'description',
'oldfieldtype': 'Text Editor',
@ -414,7 +394,6 @@
'fieldname': 'first_creation_flag',
'fieldtype': 'Int',
'hidden': 1,
'idx': 24,
'in_filter': 0,
'label': 'First Creation Flag',
'no_copy': 1,
@ -431,7 +410,6 @@
'fieldname': 'second_creation_flag',
'fieldtype': 'Int',
'hidden': 1,
'idx': 25,
'label': 'Second Creation Flag',
'no_copy': 1,
'oldfieldname': 'second_creation_flag',
@ -444,7 +422,6 @@
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 26,
'label': 'Time and Budget',
'oldfieldtype': 'Section Break',
'permlevel': 0
@ -454,7 +431,6 @@
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 27,
'label': 'Expected',
'oldfieldtype': 'Column Break',
'permlevel': 0,
@ -466,7 +442,6 @@
'doctype': 'DocField',
'fieldname': 'exp_start_date',
'fieldtype': 'Date',
'idx': 28,
'label': 'Expected Start Date',
'oldfieldname': 'exp_start_date',
'oldfieldtype': 'Date',
@ -479,7 +454,6 @@
'doctype': 'DocField',
'fieldname': 'exp_end_date',
'fieldtype': 'Date',
'idx': 29,
'in_filter': 1,
'label': 'Expected End Date',
'oldfieldname': 'exp_end_date',
@ -494,7 +468,6 @@
'doctype': 'DocField',
'fieldname': 'exp_total_hrs',
'fieldtype': 'Data',
'idx': 30,
'label': 'Total Hours (Expected)',
'oldfieldname': 'exp_total_hrs',
'oldfieldtype': 'Data',
@ -507,7 +480,6 @@
'doctype': 'DocField',
'fieldname': 'allocated_budget',
'fieldtype': 'Currency',
'idx': 31,
'label': 'Allocated Budget',
'oldfieldname': 'allocated_budget',
'oldfieldtype': 'Currency',
@ -518,7 +490,6 @@
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 32,
'label': 'Actual',
'oldfieldtype': 'Column Break',
'permlevel': 0,
@ -530,7 +501,6 @@
'doctype': 'DocField',
'fieldname': 'act_start_date',
'fieldtype': 'Date',
'idx': 33,
'label': 'Actual Start Date',
'oldfieldname': 'act_start_date',
'oldfieldtype': 'Date',
@ -542,7 +512,6 @@
'doctype': 'DocField',
'fieldname': 'act_end_date',
'fieldtype': 'Date',
'idx': 34,
'label': 'Actual End Date',
'oldfieldname': 'act_end_date',
'oldfieldtype': 'Date',
@ -554,7 +523,6 @@
'doctype': 'DocField',
'fieldname': 'act_total_hrs',
'fieldtype': 'Data',
'idx': 35,
'label': 'Total Hours (Actual)',
'oldfieldname': 'act_total_hrs',
'oldfieldtype': 'Data',
@ -566,7 +534,6 @@
'doctype': 'DocField',
'fieldname': 'actual_budget',
'fieldtype': 'Currency',
'idx': 36,
'label': 'Actual Budget',
'oldfieldname': 'actual_budget',
'oldfieldtype': 'Currency',