1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from osv import osv, fields
24 class project_compute_tasks(osv.osv_memory):
25 _name = 'project.compute.tasks'
26 _description = 'Project Compute Tasks'
28 'project_id': fields.many2one('project.project', 'Project', required=True)
31 def compute_date(self, cr, uid, ids, context=None):
33 Schedule the tasks according to users and priority.
35 project_pool = self.pool.get('project.project')
36 task_pool = self.pool.get('project.task')
39 context['compute_by'] = 'project'
40 data = self.read(cr, uid, ids, [])[0]
41 project_id = data['project_id'][0]
42 project_pool.schedule_tasks(cr, uid, [project_id], context=context)
43 return self._open_task_list(cr, uid, data, context=context)
45 def _open_task_list(self, cr, uid, data, context=None):
47 Return the scheduled task list.
51 mod_obj = self.pool.get('ir.model.data')
52 act_obj = self.pool.get('ir.actions.act_window')
53 result = mod_obj._get_id(cr, uid, 'project_long_term', 'act_resouce_allocation')
54 id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
58 result = act_obj.read(cr, uid, [id], context=context)[0]
59 result['target'] = 'current'
62 project_compute_tasks()
64 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: