diff --git a/addons/project/__openerp__.py b/addons/project/__openerp__.py index 726e87b5979..b5ff85fcc3c 100644 --- a/addons/project/__openerp__.py +++ b/addons/project/__openerp__.py @@ -56,7 +56,8 @@ work done on tasks, eso. It is able to render planning, order tasks, eso. 'board_project_demo.xml', ], 'test':[ - 'test/test_project.yml' + 'test/test_project.yml', + 'test/test_project_delegation.yml', ], 'installable': True, 'active': False, diff --git a/addons/project/project.py b/addons/project/project.py index 5ed5f9641ab..ba85b994041 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -170,6 +170,9 @@ class project(osv.osv): return res 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}) self.write(cr, uid, ids, {'state':'close'}, context=context) for (id, name) in self.name_get(cr, uid, ids): message = _('Project ') + " '" + name + "' "+ _("is Closed.") @@ -198,16 +201,37 @@ class project(osv.osv): def copy(self, cr, uid, id, default={}, context=None): if context is None: context = {} + + task_obj = self.pool.get('project.task') proj = self.browse(cr, uid, id, context=context) default = default or {} context['active_test'] = False default['state'] = 'open' if not default.get('name', False): - default['name'] = proj.name+_(' (copy)') + default['name'] = proj.name+_(' (copy)') res = super(project, self).copy(cr, uid, id, default, context) + + task_ids = task_obj.search(cr, uid, [('project_id','=', res), ('active','=',False)]) + tasks = task_obj.browse(cr, uid, task_ids) + for task in tasks: + date_deadline = None + date_end = None + if task.date_start: + ds = date(*time.strptime(task.date_start,'%Y-%m-%d %H:%M:%S')[:3]) + if task.date_deadline: + 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, + 'date_end':date_end}) + ids = self.search(cr, uid, [('parent_id','child_of', [res])]) - if ids: - cr.execute('update project_task set active=True where project_id IN %s',(tuple(ids),)) return res def duplicate_template(self, cr, uid, ids, context=None): @@ -322,6 +346,13 @@ class task(osv.osv): if task['date_start'] > task['date_end']: return False return True + + def _check_deadline_date(self, cr, uid, ids, context=None): + task = self.read(cr, uid, ids[0], ['date_start', 'date_deadline']) + if task['date_start'] and task['date_deadline']: + if task['date_deadline'] < task['date_start']: + return False + 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."), @@ -597,6 +628,15 @@ class config_compute_remaining(osv.osv_memory): _columns = { 'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Put here the remaining hours required to close the task."), } + + def _get_analytic_account(self, cr, uid, context={}): + if context.get('account_id', False): + return context.get('account_id') + return False + + _defaults = { + 'account_id' : _get_analytic_account, + } _defaults = { 'remaining_hours': _get_remaining diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index 43f01c2120d..13127969409 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -31,7 +31,7 @@ 1 Open ERP Integration - + @@ -39,21 +39,20 @@ 10 Study + Prototype - + 20 Specific Developments - + 30 Install, data import, configuration - @@ -100,7 +99,6 @@ Internal testing + Software Install - 2008-06-06 17 @@ -214,7 +212,6 @@ open In house training - 2007-06-06 50 @@ -257,7 +254,6 @@ Latest in house tests - 2010-05-27 Follow the procedure of Configuration wizard. diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 45d0e1e18bf..8fb488478ec 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -45,7 +45,7 @@ - +