1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
from openerp.osv import osv, fields
7
class dashboard_board(osv.osv):
9
_name = "dashboard.board"
10
_description = "Dashboard"
12
def extra_fields(self, cr, uid, ids, field_names, arg, context=None):
15
for board in self.browse(cr, uid, ids, context=context):
17
for widget in board.widget_ids:
21
for rel in board.widget_rel:
22
if rel.widget_id == widget.id:
23
sequence = rel.sequence
30
'method': widget.method,
31
'limit': widget.limit,
34
'metrics': widget.metrics,
44
'name': fields.char('Name'),
46
'global_field_refs': fields.serialized(string='Global Field References'),
48
'widget_ids': fields.many2many('dashboard.widget', 'dashboard_board_to_widget_rel', id1='board_id',id2='widget_id', string='Widgets', ondelete='cascade'),
51
'widget_rel': fields.one2many('dashboard.board_to_widget_rel', 'board_id', 'widget relation'),
53
'period_name': fields.selection(
54
(('day','Day'), ('week','Week'), ('month','Month'), ('quarter','Quarter'), ('semester','Semester'), ('year','Year')),
57
'period_type': fields.selection((('rolling','Rolling'), ('calendar','Calendar')), 'Period Type'),
58
'period_start_at': fields.date('Period Start', help="override Period Name and Period Type if defined"),
59
'period_end_at': fields.date('Period End', help="override Period Name and Period Type if defined"),
61
# get widget details directly by JSON-RPC (no need to query dashboard.widget on web side)
62
'widgets': fields.function(extra_fields, method=True, multi=True, type='serialized', string='Metrics Data', readonly=True),
66
'period_name': 'month',
67
'period_type': 'calendar',
68
'global_field_refs': []
75
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: