update in Task, notification and layout

This commit is contained in:
Rushabh Mehta 2012-06-04 12:57:23 +05:30
parent aaab084a12
commit 07c94ce9c0
8 changed files with 247 additions and 274 deletions

View File

@ -125,6 +125,7 @@ erpnext.desktop.show_pending_notifications = function() {
add_circle('support', 'open_support_tickets', 'Open Support Tickets');
add_circle('todo', 'things_todo', 'Things To Do');
add_circle('calendar', 'todays_events', 'Todays Events');
add_circle('project', 'open_tasks', 'Open Tasks');
erpnext.update_messages();

View File

@ -59,13 +59,6 @@ class DocType:
def validate(self):
if not self.doc.opening_date:
msgprint("Please enter Opening Date.")
raise Exception
elif getdate(self.doc.opening_date) > getdate(nowdate()):
msgprint("Opening date can not be future date")
raise Exception
if self.doc.exp_start_date and self.doc.exp_end_date and getdate(self.doc.exp_start_date) > getdate(self.doc.exp_end_date):
msgprint("'Expected Start Date' can not be greater than 'Expected End Date'")
raise Exception
@ -73,43 +66,32 @@ class DocType:
if self.doc.act_start_date and self.doc.act_end_date and getdate(self.doc.act_start_date) > getdate(self.doc.act_end_date):
msgprint("'Actual Start Date' can not be greater than 'Actual End Date'")
raise Exception
if self.doc.opening_date and self.doc.review_date and getdate(self.doc.opening_date) > getdate(self.doc.review_date):
msgprint("Review Date should be greater than or equal to Opening Date ")
raise Exception
if self.doc.closing_date and self.doc.review_date and getdate(self.doc.closing_date) < getdate(self.doc.review_date):
msgprint("Closing Date should be greater than or equal to Review Date ")
raise Exception
# on update
#--------------------------------------------
def on_update(self):
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.task_email_notify:
self.send_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 'Expected Start date'\
to add an event to allocated persons calender.You can save a task without this also.")
msgprint("Tip: Add an expected start date to create a calendar event.")
def validate_for_pending_review(self):
if not self.doc.allocated_to:
msgprint("Please enter allocated_to.")
msgprint("Please enter Allocated To.")
raise Exception
self.validate_with_timesheet_dates()
#Sent Notification
def sent_notification(self):
def send_notification(self):
i = {
'name' : self.doc.name,
'senders_name': self.doc.allocated_to,
'senders_name': self.doc.senders_name,
'opening_date': self.doc.opening_date,
'exp_start_date': self.doc.exp_start_date,
'exp_end_date' : self.doc.exp_end_date,
@ -119,8 +101,12 @@ class DocType:
'description': self.doc.description
}
task_label = '[Task Updated] '
if self.doc.creation==self.doc.modified:
task_label = '[New Task] '
msg2="""<h2>%(name)s</h2>
<p>This is a Notification for the task %(name)s that has been assigned to you
<p>This is a Notification for the task %(name)s that has been assigned / updated to you
by %(senders_name)s on %(opening_date)s</p>
<p><b>Subject:</b> %(subject)s </p>
<p><b>Project:</b> %(project)s</p>
@ -128,11 +114,9 @@ class DocType:
<p><b>Expected Start Date:</b> %(exp_start_date)s</p>
<p><b>Expected End Date:</b> %(exp_end_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')
subject= task_label + self.doc.subject)

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:06',
'creation': '2012-04-02 16:02:06',
'docstatus': 0,
'modified': '2012-03-27 14:36:06',
'modified': '2012-06-04 12:33:35',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -26,7 +26,7 @@
'show_in_menu': 0,
'subject': u'%(subject)s',
'tag_fields': u'status',
'version': 254
'version': 1
},
# These values are common for all DocField
@ -62,6 +62,7 @@
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'All',
'submit': 0,
'write': 1
},
@ -75,6 +76,7 @@
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
@ -115,6 +117,79 @@
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'allocated_to',
'fieldtype': u'Link',
'label': u'Allocated To',
'oldfieldname': u'allocated_to',
'oldfieldtype': u'Link',
'options': u'Profile',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'task_email_notify',
'fieldtype': u'Check',
'label': u'Send Mail Notification',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_start_date',
'fieldtype': u'Date',
'label': u'Expected Start Date',
'oldfieldname': u'exp_start_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_end_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Expected End Date',
'oldfieldname': u'exp_end_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'project',
'fieldtype': u'Link',
'label': u'Project',
'oldfieldname': u'project',
'oldfieldtype': u'Link',
'options': u'Project',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
@ -129,46 +204,6 @@
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'opening_date',
'fieldtype': u'Date',
'label': u'Creation Date',
'oldfieldname': u'opening_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed" || doc.status == "Pending Review"',
'doctype': u'DocField',
'fieldname': u'review_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Review Date',
'oldfieldname': u'review_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed"',
'doctype': u'DocField',
'fieldname': u'closing_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Closing Date',
'oldfieldname': u'closing_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -186,16 +221,60 @@
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'project',
'fieldtype': u'Link',
'label': u'Project',
'oldfieldname': u'project',
'oldfieldtype': u'Link',
'options': u'Project',
'fieldname': u'allocated_to_name',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Allocated To Name',
'oldfieldname': u'allocated_to_name',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'oldfieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text Editor',
'label': u'Details',
'oldfieldname': u'description',
'oldfieldtype': u'Text Editor',
'permlevel': 0,
'trigger': u'Client'
'reqd': 0,
'width': u'300px'
},
# DocField
{
'colour': u'White:FFF',
'description': u'If linked to a Customer',
'doctype': u'DocField',
'fieldname': u'customer_details',
'fieldtype': u'Section Break',
'label': u'Customer Details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'external_or_internal',
'fieldtype': u'Select',
'label': u'External or Internal',
'oldfieldname': u'external_or_internal',
'oldfieldtype': u'Select',
'options': u'External\nInternal',
'permlevel': 0
},
# DocField
@ -223,73 +302,6 @@
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'allocated_to_old',
'fieldtype': u'Link',
'hidden': 1,
'label': u'Allocated To Old',
'no_copy': 1,
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'allocated_to',
'fieldtype': u'Link',
'label': u'Allocated To',
'oldfieldname': u'allocated_to',
'oldfieldtype': u'Link',
'options': u'Profile',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'task_email_notify',
'fieldtype': u'Check',
'label': u'Sent Mail Notification',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'allocated_to_name',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Allocated To Name',
'oldfieldname': u'allocated_to_name',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sent_reminder',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Sent Reminder',
'no_copy': 1,
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -316,6 +328,14 @@
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break25',
'fieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
@ -337,102 +357,6 @@
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'external_or_internal',
'fieldtype': u'Select',
'label': u'External or Internal',
'oldfieldname': u'external_or_internal',
'oldfieldtype': u'Select',
'options': u'External\nInternal',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Amended From',
'no_copy': 1,
'oldfieldname': u'amended_from',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Amendment Date',
'no_copy': 1,
'oldfieldname': u'amendment_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'oldfieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text Editor',
'label': u'Details',
'oldfieldname': u'description',
'oldfieldtype': u'Text Editor',
'permlevel': 0,
'reqd': 0,
'width': u'300px'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'first_creation_flag',
'fieldtype': u'Int',
'hidden': 1,
'in_filter': 0,
'label': u'First Creation Flag',
'no_copy': 1,
'oldfieldname': u'first_creation_flag',
'oldfieldtype': u'Int',
'permlevel': 0,
'print_hide': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'second_creation_flag',
'fieldtype': u'Int',
'hidden': 1,
'label': u'Second Creation Flag',
'no_copy': 1,
'oldfieldname': u'second_creation_flag',
'oldfieldtype': u'Int',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
@ -455,32 +379,6 @@
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_start_date',
'fieldtype': u'Date',
'label': u'Expected Start Date',
'oldfieldname': u'exp_start_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'exp_end_date',
'fieldtype': u'Date',
'in_filter': 1,
'label': u'Expected End Date',
'oldfieldname': u'exp_end_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
@ -557,5 +455,84 @@
'oldfieldname': u'actual_budget',
'oldfieldtype': u'Currency',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'more_details',
'fieldtype': u'Section Break',
'label': u'More Details',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'opening_date',
'fieldtype': u'Date',
'label': u'Creation Date',
'oldfieldname': u'opening_date',
'oldfieldtype': u'Date',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed" || doc.status == "Pending Review"',
'doctype': u'DocField',
'fieldname': u'review_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Review Date',
'oldfieldname': u'review_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:doc.status == "Closed"',
'doctype': u'DocField',
'fieldname': u'closing_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Closing Date',
'oldfieldname': u'closing_date',
'oldfieldtype': u'Date',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Amended From',
'no_copy': 1,
'oldfieldname': u'amended_from',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'hidden': 1,
'label': u'Amendment Date',
'no_copy': 1,
'oldfieldname': u'amendment_date',
'oldfieldtype': u'Date',
'permlevel': 1,
'print_hide': 1,
'report_hide': 1
}
]
]

View File

@ -4,12 +4,12 @@
<h1>Projects</h1>
<hr>
<div style="width: 48%; float: left;">
<h4><a href="#!List/Project">Project</a></h4>
<p class="help">Project master</p>
<br>
<h4><a href="#!List/Task">Task</a></h4>
<p class="help">Project activity / task</p>
<br>
<h4><a href="#!List/Project">Project</a></h4>
<p class="help">Project master</p>
<br>
<h4><a href="#!List/Timesheet">Timesheet</a></h4>
<p class="help">Timesheet for tasks</p>
</div>

View File

@ -135,6 +135,7 @@ erpnext.update_messages = function(reset) {
show_in_circle('open_support_tickets', r.message.open_support_tickets);
show_in_circle('things_todo', r.message.things_todo);
show_in_circle('todays_events', r.message.todays_events);
show_in_circle('open_tasks', r.message.open_tasks);
} else {
clearInterval(wn.updates.id);

View File

@ -20,6 +20,15 @@ def get_open_support_tickets():
WHERE status = 'Open'""")
return open_support_tickets and cint(open_support_tickets[0][0]) or 0
def get_open_tasks():
"""
Returns a count of open tasks
"""
from webnotes.utils import cint
return webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabTask`
WHERE status = 'Open'""")[0][0]
def get_things_todo():
"""
Returns a count of incomplete todos
@ -51,4 +60,5 @@ def get_global_status_messages(arg=None):
'open_support_tickets': get_open_support_tickets(),
'things_todo': get_things_todo(),
'todays_events': get_todays_events(),
'open_tasks': get_open_tasks()
}

View File

@ -2270,7 +2270,7 @@ $('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
href="http://erpnext.com" target="_blank"></a>')}
erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);}else{clearInterval(wn.updates.id);}}
wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{erpnext.toolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
wn.updates.id=setInterval(erpnext.update_messages,60000);}

View File

@ -724,7 +724,7 @@ $('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
href="http://erpnext.com" target="_blank"></a>')}
erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);show_in_circle('open_tasks',r.message.open_tasks);}else{clearInterval(wn.updates.id);}}
wn.call({method:'startup.startup.get_global_status_messages',callback:set_messages});}else{erpnext.toolbar.set_new_comments(0);$('#unread_messages').toggle(false);}}
erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
wn.updates.id=setInterval(erpnext.update_messages,60000);}