[ADD] project_gtd: Project planning timebox fill wizard => osv memory
bzr revid: mra@tinyerp.com-20100407092305-douk9mer5hfu7z8a
This commit is contained in:
parent
48fc51335d
commit
c40d9e7224
|
@ -46,7 +46,8 @@ performing those tasks.
|
|||
'project_gtd_wizard.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/project_gtd_empty_view.xml',
|
||||
'wizard/project_gtd_daily_view.xml'
|
||||
'wizard/project_gtd_daily_view.xml',
|
||||
'wizard/project_gtd_fill_view.xml',
|
||||
],
|
||||
'demo_xml': ['project_gtd_demo.xml'],
|
||||
'installable': True,
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
<!-- parent="menu_open_time" action="open_gtd_timebox_daily"-->
|
||||
<!-- icon="STOCK_JUSTIFY_FILL" type="wizard"/>-->
|
||||
|
||||
<wizard string="Plannify Timebox"
|
||||
<!-- <wizard string="Plannify Timebox"
|
||||
model="project.gtd.timebox"
|
||||
name="project.gtd.timebox.fill"
|
||||
id="open_gtd_timebox_fill"/>
|
||||
|
||||
|
||||
-->
|
||||
<!--<wizard string="Empty Timebox"
|
||||
model="project.gtd.timebox"
|
||||
name="project.gtd.timebox.empty"
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_project_gtd_daily" model="ir.ui.view">
|
||||
<field name="name">My Daily Timebox</field>
|
||||
<field name="model">project.timebox.open</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="My Daily Timebox">
|
||||
<label string="You can open Daily Timebox"/>
|
||||
<newline/>
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
|
||||
<button name="open_tb" icon="gtk-ok" string="_Open Timebox" type="object" default_focus="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_project_gtd_daily" model="ir.actions.act_window">
|
||||
<field name="name">My Daily Timebox</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">project.timebox.open</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_project_gtd_daily"/>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="project_gtd_daily_values">
|
||||
<field name="model_id" ref="model_project_gtd_timebox" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">My Daily Timebox</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_project_gtd_daily'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">project.gtd.timebox</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -19,59 +19,43 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
from osv import osv
|
||||
class project_timebox_fill(osv.osv_memory):
|
||||
|
||||
_gtd_field = {
|
||||
'task_ids': {'relation':'project.task', 'type':'many2many', 'string':'Tasks selection'},
|
||||
'timebox_to_id': {'relation':'project.gtd.timebox', 'type':'many2one', 'string':'Set to Timebox'},
|
||||
'timebox_id': {'relation':'project.gtd.timebox', 'type':'many2one', 'string':'Get from Timebox'}
|
||||
}
|
||||
_name = 'project.timebox.fill.plan'
|
||||
_description = 'Project Timebox Fill'
|
||||
_columns = {
|
||||
'timebox_id': fields.many2one('project.gtd.timebox', 'Get from Timebox', required=True),
|
||||
'timebox_to_id': fields.many2one('project.gtd.timebox', 'Set to Timebox', required=True),
|
||||
'task_ids': fields.many2many('project.task', 'project_task_rel', 'task_id', 'fill_id', 'Tasks selection')
|
||||
}
|
||||
|
||||
_gtd_arch = """
|
||||
<form string="Timebox tasks selection" width="780">
|
||||
<field name="timebox_id" required="1"/>
|
||||
<field name="timebox_to_id" required="1"/>
|
||||
<field name="task_ids" nolabel="1" colspan="4" height="450" domain="[('timebox_id','=',timebox_id),('state','=','open')]"/>
|
||||
</form>
|
||||
"""
|
||||
def _get_from_tb(self, cr, uid, context=None):
|
||||
ids = self.pool.get('project.gtd.timebox').search(cr, uid, [], context=context)
|
||||
return ids and ids[0] or False
|
||||
|
||||
class wiz_timebox_fill(wizard.interface):
|
||||
def _fill(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = pool.get('project.gtd.timebox').search(cr, uid, [], context=context)
|
||||
return {
|
||||
'timebox_id': ids and ids[0] or False,
|
||||
'timebox_to_id': data['id']
|
||||
}
|
||||
def _get_to_tb(self, cr, uid, context=None):
|
||||
if 'active_id' in context:
|
||||
return context['active_id']
|
||||
return False
|
||||
|
||||
def _process(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
ids = data['form']['task_ids']
|
||||
pool.get('project.task').write(cr, uid, ids[0][2], {'timebox_id':data['form']['timebox_to_id']})
|
||||
_defaults = {
|
||||
'timebox_id': _get_from_tb,
|
||||
'timebox_to_id': _get_to_tb,
|
||||
}
|
||||
|
||||
def process(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not ids:
|
||||
return {}
|
||||
data = self.read(cr, uid, ids, [])
|
||||
if not data[0]['task_ids']:
|
||||
return {}
|
||||
self.pool.get('project.task').write(cr, uid, data[0]['task_ids'], {'timebox_id':data[0]['timebox_to_id']})
|
||||
return {}
|
||||
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [_fill],
|
||||
'result' : {
|
||||
'type':'form',
|
||||
'arch':_gtd_arch,
|
||||
'fields':_gtd_field,
|
||||
'state':[
|
||||
('end','Cancel', 'gtk-cancel'),
|
||||
('process','Add to Timebox')
|
||||
]
|
||||
}
|
||||
},
|
||||
'process' : {
|
||||
'actions' : [_process],
|
||||
'result' : {'type':'state', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wiz_timebox_fill('project.gtd.timebox.fill')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
project_timebox_fill()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_project_gtd_fill" model="ir.ui.view">
|
||||
<field name="name">Plannify Timebox</field>
|
||||
<field name="model">project.timebox.fill.plan</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Plannify Timebox">
|
||||
<field name="timebox_id" />
|
||||
<field name="timebox_to_id" />
|
||||
<field colspan="4" name="task_ids" nolabel="1" domain="[('timebox_id','=',timebox_id),('state','=','open')]" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
|
||||
<button name="process" icon="gtk-ok" string="Add to Timebox" type="object" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_project_gtd_fill" model="ir.actions.act_window">
|
||||
<field name="name">Plannify Timebox</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">project.timebox.fill.plan</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_project_gtd_fill"/>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="project_gtd_fill_values">
|
||||
<field name="model_id" ref="model_project_gtd_timebox" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Plannify Timebox</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_project_gtd_fill'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">project.gtd.timebox</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue