[IMP] project: when cancelling a project, all its tasks are cancelled too
bzr revid: qdp-launchpad@tinyerp.com-20100713195411-awbi447icz25k232
This commit is contained in:
parent
fc9cee7b2b
commit
f7f4db9ce1
|
@ -21,7 +21,7 @@
|
|||
|
||||
from lxml import etree
|
||||
import time
|
||||
|
||||
from datetime import date, datetime
|
||||
from tools.translate import _
|
||||
from osv import fields, osv
|
||||
|
||||
|
@ -171,8 +171,8 @@ class project(osv.osv):
|
|||
|
||||
def set_done(self, cr, uid, ids, context=None):
|
||||
task_obj = self.pool.get('project.task')
|
||||
for task in self.read(cr, uid, ids, ['tasks'])[0]['tasks']:
|
||||
task_obj.write(cr, uid, task, {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
|
||||
task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', 'not in', ('cancelled', 'done'))])
|
||||
task_obj.write(cr, uid, task_ids, {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
|
||||
self.write(cr, uid, ids, {'state':'close'}, context=context)
|
||||
for (id, name) in self.name_get(cr, uid, ids):
|
||||
message = _('Project ') + " '" + name + "' "+ _("is Closed.")
|
||||
|
@ -180,6 +180,9 @@ class project(osv.osv):
|
|||
return True
|
||||
|
||||
def set_cancel(self, cr, uid, ids, context=None):
|
||||
task_obj = self.pool.get('project.task')
|
||||
task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', '!=', 'done')])
|
||||
task_obj.write(cr, uid, task_ids, {'state': 'cancelled', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
|
||||
self.write(cr, uid, ids, {'state':'cancelled'}, context=context)
|
||||
return True
|
||||
|
||||
|
@ -222,10 +225,6 @@ class project(osv.osv):
|
|||
dd = date(*time.strptime(task.date_deadline,'%Y-%m-%d')[:3])
|
||||
diff = dd-ds
|
||||
date_deadline = (datetime.now()+diff).strftime('%Y-%m-%d %H:%M:%S')
|
||||
if task.date_end:
|
||||
de = date(*time.strptime(task.date_end,'%Y-%m-%d %H:%M:%S')[:3])
|
||||
diff = de-ds
|
||||
date_end = (datetime.now()+diff).strftime('%Y-%m-%d %H:%M:%S')
|
||||
task_obj.write(cr, uid, task.id, {'active':True,
|
||||
'date_start':time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'date_deadline':date_deadline,
|
||||
|
@ -355,7 +354,7 @@ class task(osv.osv):
|
|||
return True
|
||||
|
||||
_columns = {
|
||||
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the task without removing it."),
|
||||
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the task without removing it. This is basically used for the management of templates of projects and tasks."),
|
||||
'name': fields.char('Task Summary', size=128, required=True),
|
||||
'description': fields.text('Description'),
|
||||
'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance'),
|
||||
|
|
|
@ -109,23 +109,24 @@
|
|||
- state == "open"
|
||||
|
||||
|
||||
|
||||
-
|
||||
Test for task work allocation
|
||||
-
|
||||
Check if task 'Technical Training' in draft state
|
||||
-
|
||||
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Project is in draft state}:
|
||||
- state == "draft"
|
||||
-
|
||||
Open task 'Technical Training'
|
||||
-
|
||||
!python {model: project.task}: |
|
||||
self.do_open(cr, uid, [ref("project_task_technicaltraining0")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")],
|
||||
"tz": False, "active_model": "ir.ui.menu", "search_default_project_id":
|
||||
False, "search_default_user_id": 1, "search_default_current": 1, "project_id":
|
||||
False, "active_id": ref("project.menu_action_view_task"), })
|
||||
-
|
||||
-
|
||||
As i cancelled my project before, i check if the task 'Technical Training' is in cancelled state
|
||||
-
|
||||
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Task is in cancelled state}:
|
||||
- state == "cancelled"
|
||||
-
|
||||
Now in order to reactivate the task 'Technical Training', i click on the "Reactivate" button and fill the remaining hour field
|
||||
-
|
||||
!record {model: config.compute.remaining, id: project_task_technicaltraining_remainingwiz0}:
|
||||
remaining_hours: 30.0
|
||||
- |
|
||||
I click the apply button
|
||||
-
|
||||
!python {model: config.compute.remaining}: |
|
||||
self.compute_hours(cr, uid, [ref('project_task_technicaltraining_remainingwiz0')], {'active_id': ref("project_task_technicaltraining0"),'button_reactivate': True})
|
||||
- |
|
||||
Check if task 'Technical Training' in open state and for other initial values
|
||||
-
|
||||
!assert {model: project.task, id: project_task_technicaltraining0, severity: error, string: Project is in open state}:
|
||||
|
@ -231,10 +232,7 @@
|
|||
Close the task
|
||||
-
|
||||
!python {model: project.task}: |
|
||||
self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")],
|
||||
"tz": False, "active_model": "ir.ui.menu", "search_default_project_id":
|
||||
False, "search_default_user_id": 1, "search_default_current": 1, "project_id":
|
||||
False, "active_id": ref("project.menu_action_view_task"), })
|
||||
self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {'mail_send': False})
|
||||
-
|
||||
Check if task in done state
|
||||
-
|
||||
|
@ -289,10 +287,7 @@
|
|||
Close the task
|
||||
-
|
||||
!python {model: project.task}: |
|
||||
self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {"lang": "en_US", "active_ids": [ref("project.menu_action_view_task")],
|
||||
"tz": False, "active_model": "ir.ui.menu", "search_default_project_id":
|
||||
False, "search_default_user_id": 1, "search_default_current": 1, "project_id":
|
||||
False, "active_id": ref("project.menu_action_view_task"), })
|
||||
self.do_close(cr, uid, [ref("project_task_technicaltraining0")], {'mail_send': False})
|
||||
-
|
||||
Check if task in done state
|
||||
-
|
||||
|
@ -319,4 +314,4 @@
|
|||
-
|
||||
!assert {model: project.project, id: project_project_openerptrainingprogramme0, severity: error}:
|
||||
- state == "close"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue