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.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax 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 import session, form, is_testing, msgprint, errprint
sql = webnotes.conn.sql sql = webnotes.conn.sql
set = webnotes.conn.set
get_value = webnotes.conn.get_value
# ----------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------
@ -31,7 +31,7 @@ class DocType:
return ret return ret
def get_allocated_to_name(self): 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 ''} ret = { 'allocated_to_name' : as_em and (as_em[0][0] + ' ' + as_em[0][1]) or ''}
return ret return ret
@ -67,6 +67,12 @@ class DocType:
#-------------------------------------------- #--------------------------------------------
def on_update(self): 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 pass
#validate before sending for approval #validate before sending for approval

View File

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