2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-08-24 14:45:43 +00:00
|
|
|
##############################################################################
|
2010-04-07 06:24:16 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-04-07 06:24:16 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-08-24 14:45:43 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
2010-08-12 07:31:45 +00:00
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
|
|
|
from openerp.tools.translate import _
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-04-07 06:24:16 +00:00
|
|
|
class project_timebox_empty(osv.osv_memory):
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-04-07 06:24:16 +00:00
|
|
|
_name = 'project.timebox.empty'
|
|
|
|
_description = 'Project Timebox Empty'
|
|
|
|
_columns = {
|
|
|
|
'name': fields.char('Name', size=32)
|
2010-08-13 12:20:05 +00:00
|
|
|
}
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2012-03-05 18:40:03 +00:00
|
|
|
def view_init(self, cr, uid, fields_list, context=None):
|
2010-04-07 06:24:16 +00:00
|
|
|
if context is None:
|
|
|
|
context = {}
|
|
|
|
self._empty(cr, uid, context=context)
|
|
|
|
pass
|
|
|
|
|
|
|
|
def _empty(self, cr, uid, context=None):
|
2008-08-24 14:45:43 +00:00
|
|
|
close = []
|
|
|
|
up = []
|
2010-04-07 06:24:16 +00:00
|
|
|
obj_tb = self.pool.get('project.gtd.timebox')
|
|
|
|
obj_task = self.pool.get('project.task')
|
|
|
|
|
|
|
|
if context is None:
|
|
|
|
context = {}
|
|
|
|
if not 'active_id' in context:
|
|
|
|
return {}
|
|
|
|
|
|
|
|
ids = obj_tb.search(cr, uid, [], context=context)
|
|
|
|
if not len(ids):
|
2013-06-07 11:38:29 +00:00
|
|
|
raise osv.except_osv(_('Error!'), _('No timebox child of this one!'))
|
2010-04-07 06:24:16 +00:00
|
|
|
tids = obj_task.search(cr, uid, [('timebox_id', '=', context['active_id'])])
|
|
|
|
for task in obj_task.browse(cr, uid, tids, context):
|
|
|
|
if (task.state in ('cancel','done')) or (task.user_id.id <> uid):
|
2008-08-24 14:45:43 +00:00
|
|
|
close.append(task.id)
|
|
|
|
else:
|
|
|
|
up.append(task.id)
|
|
|
|
if up:
|
2010-04-07 06:24:16 +00:00
|
|
|
obj_task.write(cr, uid, up, {'timebox_id':ids[0]})
|
2008-08-24 14:45:43 +00:00
|
|
|
if close:
|
2010-04-07 06:24:16 +00:00
|
|
|
obj_task.write(cr, uid, close, {'timebox_id':False})
|
2008-08-24 14:45:43 +00:00
|
|
|
return {}
|
|
|
|
|
2010-04-07 06:24:16 +00:00
|
|
|
project_timebox_empty()
|
2008-08-24 14:45:43 +00:00
|
|
|
|
2010-07-02 14:37:06 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|