[ADD] project_gtd: Project timebox empty wizard => osv memory
bzr revid: mra@tinyerp.com-20100407062416-zjbwr9zme1zxroqs
This commit is contained in:
parent
69aa483b1c
commit
2be4475cba
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -45,6 +45,7 @@ performing those tasks.
|
|||
'project_gtd_view.xml',
|
||||
'project_gtd_wizard.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/project_gtd_empty_view.xml'
|
||||
],
|
||||
'demo_xml': ['project_gtd_demo.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
<!-- <menuitem name="My Daily Timebox" id="menu_open_time_daily_inbox" -->
|
||||
<!-- parent="menu_open_time" action="open_gtd_timebox_daily"-->
|
||||
<!-- icon="STOCK_JUSTIFY_FILL" type="wizard"/>-->
|
||||
|
||||
|
||||
<wizard string="Plannify Timebox"
|
||||
model="project.gtd.timebox"
|
||||
name="project.gtd.timebox.fill"
|
||||
id="open_gtd_timebox_fill"/>
|
||||
|
||||
|
||||
<wizard string="Empty Timebox"
|
||||
<!--<wizard string="Empty Timebox"
|
||||
model="project.gtd.timebox"
|
||||
name="project.gtd.timebox.empty"
|
||||
id="open_gtd_timebox_empty"/>
|
||||
|
||||
-->
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,46 +15,52 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
import wizard
|
||||
import netsvc
|
||||
import time
|
||||
import pooler
|
||||
from osv import osv
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class wiz_timebox_empty(wizard.interface):
|
||||
def _empty(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = pool.get('project.gtd.timebox').search(cr, uid, [])
|
||||
if not len(ids):
|
||||
raise wizard.except_wizard(_('Error !'), _('No timebox child of this one !'))
|
||||
tids = pool.get('project.task').search(cr, uid, [('timebox_id','=',data['id'])])
|
||||
class project_timebox_empty(osv.osv_memory):
|
||||
|
||||
_name = 'project.timebox.empty'
|
||||
_description = 'Project Timebox Empty'
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=32)
|
||||
}
|
||||
|
||||
def view_init(self, cr , uid , fields_list, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
self._empty(cr, uid, context=context)
|
||||
pass
|
||||
|
||||
def _empty(self, cr, uid, context=None):
|
||||
close = []
|
||||
up = []
|
||||
for task in pool.get('project.task').browse(cr, uid, tids, context):
|
||||
if (task.state in ('cancel','done')) or (task.user_id.id<>uid):
|
||||
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):
|
||||
raise osv.except_osv(_('Error !'), _('No timebox child of this one !'))
|
||||
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):
|
||||
close.append(task.id)
|
||||
else:
|
||||
up.append(task.id)
|
||||
if up:
|
||||
pool.get('project.task').write(cr, uid, up, {'timebox_id':ids[0]})
|
||||
obj_task.write(cr, uid, up, {'timebox_id':ids[0]})
|
||||
if close:
|
||||
pool.get('project.task').write(cr, uid, close, {'timebox_id':False})
|
||||
obj_task.write(cr, uid, close, {'timebox_id':False})
|
||||
return {}
|
||||
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [_empty],
|
||||
'result' : {'type':'state', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wiz_timebox_empty('project.gtd.timebox.empty')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
project_timebox_empty()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_project_gtd_empty" model="ir.ui.view">
|
||||
<field name="name">Empty Timebox</field>
|
||||
<field name="model">project.timebox.empty</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Empty Timebox">
|
||||
<label string="Timebox Empty Process Completed Successfully."/>
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-ok" colspan="4" special="cancel" string="_Ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_project_gtd_empty" model="ir.actions.act_window">
|
||||
<field name="name">Empty Timebox</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">project.timebox.empty</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_project_gtd_empty"/>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="project_gtd_empty_values">
|
||||
<field name="model_id" ref="model_project_gtd_timebox" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Empty Timebox</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_project_gtd_empty'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">project.gtd.timebox</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue