Dashboard Definition Tool
bzr revid: fp@tinyerp.com-4117df4cb89ab9bbf30150b9e0b8b3c2abc1ad40
This commit is contained in:
+58
-7
@@ -29,17 +29,68 @@
|
||||
import time
|
||||
from osv import fields,osv
|
||||
|
||||
class board(osv.osv):
|
||||
class board_board(osv.osv):
|
||||
_name = 'board.board'
|
||||
def create(self, cr, user, vals, context={}):
|
||||
return False
|
||||
def copy(self, cr, uid, id, default=None, context={}):
|
||||
return False
|
||||
def create(self, cr, user, vals, context=None):
|
||||
if not 'name' in vals:
|
||||
return False
|
||||
return super(board_board, self).create(cr, user, vals, context)
|
||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
||||
if context and ('view' in context):
|
||||
board = self.pool.get('board.board').browse(cr, user, int(context['view']), context)
|
||||
left = []
|
||||
right = []
|
||||
for line in board.line_ids:
|
||||
linestr = '<action string="%s" name="%d" colspan="4"' % (line.name, line.action_id.id)
|
||||
if line.height:
|
||||
linestr+=(' height="%d"' % (line.height,))
|
||||
if line.width:
|
||||
linestr+=(' width="%d"' % (line.width,))
|
||||
linestr += '/>'
|
||||
if line.position=='left':
|
||||
left.append(linestr)
|
||||
else:
|
||||
right.append(linestr)
|
||||
arch = """<form string="My Board">
|
||||
<hpaned>
|
||||
<child1>
|
||||
%s
|
||||
</child1>
|
||||
<child2>
|
||||
%s
|
||||
</child2>
|
||||
</hpaned>
|
||||
</form>""" % ('\n'.join(left), '\n'.join(right))
|
||||
result = {
|
||||
'toolbar': {'print':[],'action':[],'relate':[]},
|
||||
'fields': {},
|
||||
'arch': arch
|
||||
}
|
||||
return result
|
||||
res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
|
||||
return res
|
||||
_columns = {
|
||||
'name': fields.char('Board', size=64),
|
||||
'name': fields.char('Board', size=64, required=True),
|
||||
'line_ids': fields.one2many('board.board.line', 'board_id', 'Action Views')
|
||||
}
|
||||
board()
|
||||
board_board()
|
||||
|
||||
class board_line(osv.osv):
|
||||
_name = 'board.board.line'
|
||||
_order = 'position,sequence'
|
||||
_columns = {
|
||||
'name': fields.char('Board', size=64, required=True),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
'height': fields.integer('Height'),
|
||||
'width': fields.integer('Width'),
|
||||
'board_id': fields.many2one('board.board', 'Dashboard', required=True, ondelete='cascade'),
|
||||
'action_id': fields.many2one('ir.actions.act_window', 'Action', required=True),
|
||||
'position': fields.selection([('left','Left'),('right','Right')], 'Position', required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'position': lambda *args: 'left'
|
||||
}
|
||||
board_line()
|
||||
|
||||
class board_note_type(osv.osv):
|
||||
_name = 'board.note.type'
|
||||
|
||||
@@ -39,5 +39,62 @@
|
||||
action="action_view_board_note_form"
|
||||
sequence="100"
|
||||
id="menu_view_board_note_form"/>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_board_tree">
|
||||
<field name="name">board.board.tree</field>
|
||||
<field name="model">board.board</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Dashboard">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_board_form">
|
||||
<field name="name">board.board.form</field>
|
||||
<field name="model">board.board</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority" eval="1"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Dashboard">
|
||||
<field name="name" select="1"/>
|
||||
<field name="line_ids" colspan="4">
|
||||
<tree string="Dashboard View">
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
<field name="action_id"/>
|
||||
<field name="position"/>
|
||||
</tree>
|
||||
<form string="Dashboard View">
|
||||
<field name="name"/>
|
||||
<field name="sequence"/>
|
||||
<field name="width"/>
|
||||
<field name="height"/>
|
||||
<field name="action_id"/>
|
||||
<field name="position"/>
|
||||
</form>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_view_board_list_form">
|
||||
<field name="name">Dashboard Definition</field>
|
||||
<field name="res_model">board.board</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Dashboards/Configuration/Dashboard Definition"
|
||||
action="action_view_board_list_form"
|
||||
id="menu_view_board_form"/>
|
||||
|
||||
|
||||
<act_window name="Open Dashboard"
|
||||
context="{'view': active_id}"
|
||||
res_model="board.board"
|
||||
src_model="board.board"
|
||||
id="dashboard_open"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
||||
Reference in New Issue
Block a user