2008-07-23 14:41:47 +00:00
|
|
|
# -*- encoding: utf-8 -*-
|
2006-12-15 07:15:10 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2009-01-04 22:12:50 +00:00
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
2008-11-03 19:18:56 +00:00
|
|
|
# $Id$
|
2008-06-16 11:00:21 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2006-12-15 07:15:10 +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
|
|
|
|
# GNU General Public License for more details.
|
2006-12-15 07:15:10 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-12-15 07:15:10 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
import time
|
|
|
|
from osv import fields,osv
|
|
|
|
|
2007-12-18 21:30:26 +00:00
|
|
|
class board_board(osv.osv):
|
2008-07-22 15:11:28 +00:00
|
|
|
_name = 'board.board'
|
2008-07-25 10:20:22 +00:00
|
|
|
|
|
|
|
def create_view(self, cr, uid, ids, context):
|
|
|
|
|
|
|
|
board = self.pool.get('board.board').browse(cr, uid, ids, 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 = """<?xml version="1.0"?>
|
|
|
|
<form string="My Board">
|
|
|
|
<hpaned>
|
|
|
|
<child1>
|
|
|
|
%s
|
|
|
|
</child1>
|
|
|
|
<child2>
|
|
|
|
%s
|
|
|
|
</child2>
|
|
|
|
</hpaned>
|
|
|
|
</form>""" % ('\n'.join(left), '\n'.join(right))
|
|
|
|
|
|
|
|
return arch
|
|
|
|
|
|
|
|
def write(self, cr, uid, ids, vals, context={}):
|
|
|
|
result = super(board_board, self).write(cr, uid, ids, vals, context)
|
|
|
|
cr.commit()
|
|
|
|
|
2008-08-06 13:52:05 +00:00
|
|
|
board = self.pool.get('board.board').browse(cr, uid, ids[0])
|
2008-07-26 08:35:54 +00:00
|
|
|
|
|
|
|
view = self.create_view(cr, uid, ids[0], context)
|
2008-08-06 13:52:05 +00:00
|
|
|
id = board.view_id.id
|
2008-07-26 08:35:54 +00:00
|
|
|
|
2008-12-10 14:29:55 +00:00
|
|
|
cr.execute("update ir_ui_view set arch='%s' where id=%s" % (view, id))
|
2008-07-26 08:35:54 +00:00
|
|
|
cr.commit()
|
2008-08-06 13:52:05 +00:00
|
|
|
|
2008-07-25 10:20:22 +00:00
|
|
|
return result
|
|
|
|
|
2008-07-22 15:11:28 +00:00
|
|
|
def create(self, cr, user, vals, context=None):
|
|
|
|
if not 'name' in vals:
|
|
|
|
return False
|
2008-07-25 10:20:22 +00:00
|
|
|
id = super(board_board, self).create(cr, user, vals, context)
|
|
|
|
view_id = self.pool.get('ir.ui.view').create(cr, user, {
|
|
|
|
'name': vals['name'],
|
|
|
|
'model':'board.board',
|
|
|
|
'priority':16,
|
|
|
|
'type': 'form',
|
|
|
|
'arch': self.create_view(cr, user, id, context),
|
|
|
|
})
|
2009-04-09 10:02:19 +00:00
|
|
|
|
2009-04-06 13:40:39 +00:00
|
|
|
super(board_board, self).write(cr, user, [id], {'view_id': view_id}, context)
|
2009-04-09 10:02:19 +00:00
|
|
|
|
2008-07-25 10:20:22 +00:00
|
|
|
return id
|
|
|
|
|
2008-07-22 15:11:28 +00:00
|
|
|
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
2008-07-26 08:35:54 +00:00
|
|
|
res = {}
|
2008-08-06 13:52:05 +00:00
|
|
|
res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar)
|
|
|
|
|
|
|
|
vids = self.pool.get('ir.ui.view.custom').search(cr, user, [('user_id','=',user), ('ref_id','=',view_id)])
|
2008-07-26 08:35:54 +00:00
|
|
|
if vids:
|
|
|
|
view_id = vids[0]
|
2008-08-06 13:52:05 +00:00
|
|
|
arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id)
|
|
|
|
res['arch'] = arch.arch
|
|
|
|
|
2008-07-22 15:11:28 +00:00
|
|
|
res['toolbar'] = {'print':[],'action':[],'relate':[]}
|
|
|
|
return res
|
2008-07-26 08:35:54 +00:00
|
|
|
|
2008-07-22 15:11:28 +00:00
|
|
|
_columns = {
|
|
|
|
'name': fields.char('Dashboard', size=64, required=True),
|
2008-07-25 10:20:22 +00:00
|
|
|
'view_id': fields.many2one('ir.ui.view', 'Board View'),
|
2008-07-22 15:11:28 +00:00
|
|
|
'line_ids': fields.one2many('board.board.line', 'board_id', 'Action Views')
|
|
|
|
}
|
2009-01-03 09:17:06 +00:00
|
|
|
|
|
|
|
# the following lines added to let the button on dashboard work.
|
|
|
|
_defaults = {
|
|
|
|
'name': lambda *args: 'Dashboard'
|
|
|
|
}
|
|
|
|
|
2007-12-18 21:30:26 +00:00
|
|
|
board_board()
|
2006-12-15 07:15:10 +00:00
|
|
|
|
2007-12-18 21:30:26 +00:00
|
|
|
class board_line(osv.osv):
|
2008-07-22 15:11:28 +00:00
|
|
|
_name = 'board.board.line'
|
|
|
|
_order = 'position,sequence'
|
|
|
|
_columns = {
|
2008-08-06 07:09:29 +00:00
|
|
|
'name': fields.char('Title', size=64, required=True),
|
2008-07-22 15:11:28 +00:00
|
|
|
'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'
|
|
|
|
}
|
2007-12-18 21:30:26 +00:00
|
|
|
board_line()
|
2006-12-15 07:15:10 +00:00
|
|
|
|
|
|
|
class board_note_type(osv.osv):
|
2008-07-22 15:11:28 +00:00
|
|
|
_name = 'board.note.type'
|
|
|
|
_columns = {
|
|
|
|
'name': fields.char('Note Type', size=64, required=True),
|
|
|
|
}
|
2006-12-15 07:15:10 +00:00
|
|
|
board_note_type()
|
|
|
|
|
|
|
|
def _type_get(self, cr, uid, context={}):
|
2008-07-22 15:11:28 +00:00
|
|
|
obj = self.pool.get('board.note.type')
|
|
|
|
ids = obj.search(cr, uid, [])
|
|
|
|
res = obj.read(cr, uid, ids, ['name'], context)
|
|
|
|
res = [(r['name'], r['name']) for r in res]
|
|
|
|
return res
|
2006-12-15 07:15:10 +00:00
|
|
|
|
|
|
|
class board_note(osv.osv):
|
2008-07-22 15:11:28 +00:00
|
|
|
_name = 'board.note'
|
|
|
|
_columns = {
|
|
|
|
'name': fields.char('Subject', size=128, required=True),
|
|
|
|
'note': fields.text('Note'),
|
|
|
|
'user_id': fields.many2one('res.users', 'Author', size=64),
|
|
|
|
'date': fields.date('Date', size=64, required=True),
|
|
|
|
'type': fields.selection(_type_get, 'Note type', size=64),
|
|
|
|
}
|
|
|
|
_defaults = {
|
|
|
|
'user_id': lambda object,cr,uid,context: uid,
|
|
|
|
'date': lambda object,cr,uid,context: time.strftime('%Y-%m-%d'),
|
|
|
|
}
|
2006-12-15 07:15:10 +00:00
|
|
|
board_note()
|
2008-07-23 14:41:47 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|