diff options
| author | uco <uco@tinyerp.com> | 2010-07-10 10:25:33 +0530 |
|---|---|---|
| committer | uco <uco@tinyerp.com> | 2010-07-10 10:25:33 +0530 |
| commit | df65d72814b245970d0d2dfca4bcd9c2ca85f9a7 (patch) | |
| tree | 58fa147b64f35ee2b5c8951d3daa9566fe0ae910 /addons/project/wizard | |
| parent | 2185d20b4c7dafe40ad5c0a484207e58eeacbd42 (diff) | |
| parent | b051735eecccd1e66d8f28d2ff50ba45435b49f7 (diff) | |
[MERGE]
bzr revid: uco@tinyerp.com-20100710045533-op3teksgyqouzv0o
Diffstat (limited to 'addons/project/wizard')
| -rw-r--r-- | addons/project/wizard/project_close_task.py | 20 | ||||
| -rw-r--r-- | addons/project/wizard/project_close_task_view.xml | 8 | ||||
| -rw-r--r-- | addons/project/wizard/project_task_delegate.py | 15 |
3 files changed, 28 insertions, 15 deletions
diff --git a/addons/project/wizard/project_close_task.py b/addons/project/wizard/project_close_task.py index b1cd933a4f7..715e70e59d0 100644 --- a/addons/project/wizard/project_close_task.py +++ b/addons/project/wizard/project_close_task.py @@ -19,8 +19,9 @@ # ############################################################################## -from osv import fields, osv +import time +from osv import fields, osv from tools.translate import _ from tools import email_send as email @@ -42,7 +43,7 @@ class project_close_task(osv.osv_memory): if 'task_id' in context: task = self.pool.get('project.task').browse(cr, uid, context['task_id']) partner_id = task.partner_id or task.project_id.partner_id - if partner_id and partner_id.address[0].email: + if partner_id and len(partner_id.address) and partner_id.address[0].email: email = partner_id.address[0].email return email @@ -54,10 +55,15 @@ class project_close_task(osv.osv_memory): return task.description or task.name return '' - _defaults={ + _defaults = { 'email': _get_email, 'description': _get_desc, } + + def close(self, cr, uid, ids, context=None): + if 'task_id' in context: + self.pool.get('project.task').write(cr, uid, [context['task_id']], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0}) + return {} def confirm(self, cr, uid, ids, context=None): if context is None: @@ -67,8 +73,10 @@ class project_close_task(osv.osv_memory): close_task = self.read(cr, uid, ids[0], []) to_adr = close_task['email'] description = close_task['description'] + if 'task_id' in context: - for task in self.pool.get('project.task').browse(cr, uid, [context['task_id']], context=context): + task_obj = self.pool.get('project.task') + for task in task_obj.browse(cr, uid, [context['task_id']], context=context): project = task.project_id subject = "Task '%s' closed" % task.name if task.user_id and task.user_id.address_id and task.user_id.address_id.email: @@ -89,9 +97,11 @@ class project_close_task(osv.osv_memory): footer = (project.warn_footer or '') % val body = u'%s\n%s\n%s\n\n-- \n%s' % (header, description, footer, signature) email(from_adr, [to_adr], subject, body.encode('utf-8'), email_bcc=[from_adr]) + task_obj.write(cr, uid, [task.id], {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0}) else: - raise osv.except_osv(_('Error'), _("Couldn't send mail because the contact for this task (%s) has no email address!") % contact.name) + raise osv.except_osv(_('Error'), _("Please specify the email address of partner.")) return {} project_close_task() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/wizard/project_close_task_view.xml b/addons/project/wizard/project_close_task_view.xml index f9206152b25..e46ddf7d6da 100644 --- a/addons/project/wizard/project_close_task_view.xml +++ b/addons/project/wizard/project_close_task_view.xml @@ -16,9 +16,11 @@ <newline/> <field name="description" /> </group> - <group colspan="4" col="6"> - <button icon="gtk-cancel" special="cancel" string="_Close"/> - <button icon="gtk-ok" name="confirm" string="Send Mail" type="object"/> + <separator string="" colspan="6"/> + <group colspan="6" col="6"> + <button icon="gtk-ok" name="confirm" string="Send and Close" type="object"/> + <button icon="gtk-ok" string="Close" name="close" type="object"/> + <button icon="gtk-cancel" special="cancel" string="_Cancel"/> </group> </form> </field> diff --git a/addons/project/wizard/project_task_delegate.py b/addons/project/wizard/project_task_delegate.py index 779909273df..850f27b99d4 100644 --- a/addons/project/wizard/project_task_delegate.py +++ b/addons/project/wizard/project_task_delegate.py @@ -102,19 +102,20 @@ class project_task_delegate(osv.osv_memory): 'description': delegate_data['new_task_description'] or '', 'child_ids': [], 'work_ids': [] - }) + }, context) task_obj.write(cr, uid, [task.id], { 'remaining_hours': delegate_data['planned_hours_me'], 'planned_hours': delegate_data['planned_hours_me'] + (task.effective_hours or 0.0), 'name': newname, - }) + }, context) if delegate_data['state'] == 'pending': - task_obj.do_pending(cr, uid, [task.id]) + task_obj.do_pending(cr, uid, [task.id], context) else: - task_obj.do_close(cr, uid, [task.id]) - delegrate_user = user_obj.browse(cr, uid, delegate_data['user_id'], context=context) - message = _('Task ') + " '" + delegate_data['name'] + "' "+ _("is Delegated to User:") +" '"+ delegrate_user.name +"' " - self.log(cr, uid, task.id, message) + context.update({'mail_send': False} ) + task_obj.do_close(cr, uid, [task.id], context) + delegrate_user = user_obj.browse(cr, uid, delegate_data['user_id'], context=context) + message = _('Task ') + " '" + delegate_data['name'] + "' "+ _("is Delegated to User:") +" '"+ delegrate_user.name +"' " + self.log(cr, uid, task.id, message) return {} project_task_delegate() |
