[IMP]:board: code optimization and apply doc string
bzr revid: atp@tinyerp.co.in-20100317050634-2zwf6ti18md6552h
This commit is contained in:
parent
e73dd6009e
commit
7a129bfc5d
|
@ -23,4 +23,3 @@ import board
|
|||
import wizard
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'name': 'Dashboard main module',
|
||||
'version': '1.0',
|
||||
|
|
|
@ -23,13 +23,18 @@ import time
|
|||
from osv import fields,osv
|
||||
|
||||
class board_board(osv.osv):
|
||||
"""
|
||||
Board
|
||||
"""
|
||||
_name = 'board.board'
|
||||
|
||||
_description = "Board"
|
||||
|
||||
def create_view(self, cr, uid, ids, context):
|
||||
|
||||
board = self.pool.get('board.board').browse(cr, uid, ids, context)
|
||||
left = []
|
||||
right = []
|
||||
#start Loop
|
||||
for line in board.line_ids:
|
||||
linestr = '<action string="%s" name="%d" colspan="4"' % (line.name, line.action_id.id)
|
||||
if line.height:
|
||||
|
@ -41,6 +46,7 @@ class board_board(osv.osv):
|
|||
left.append(linestr)
|
||||
else:
|
||||
right.append(linestr)
|
||||
#End Loop
|
||||
arch = """<?xml version="1.0"?>
|
||||
<form string="My Board">
|
||||
<hpaned>
|
||||
|
@ -69,6 +75,9 @@ class board_board(osv.osv):
|
|||
return result
|
||||
|
||||
def create(self, cr, user, vals, context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
if not 'name' in vals:
|
||||
return False
|
||||
id = super(board_board, self).create(cr, user, vals, context)
|
||||
|
@ -85,6 +94,9 @@ class board_board(osv.osv):
|
|||
return id
|
||||
|
||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
if not context:
|
||||
context={}
|
||||
|
||||
res = {}
|
||||
res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
|
||||
|
||||
|
@ -110,8 +122,13 @@ class board_board(osv.osv):
|
|||
|
||||
board_board()
|
||||
|
||||
|
||||
class board_line(osv.osv):
|
||||
"""
|
||||
Board Line
|
||||
"""
|
||||
_name = 'board.board.line'
|
||||
_description = "Board Line"
|
||||
_order = 'position,sequence'
|
||||
_columns = {
|
||||
'name': fields.char('Title', size=64, required=True),
|
||||
|
@ -120,15 +137,21 @@ class board_line(osv.osv):
|
|||
'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)
|
||||
'position': fields.selection([('left','Left'),
|
||||
('right','Right')], 'Position', required=True)
|
||||
}
|
||||
_defaults = {
|
||||
'position': lambda *args: 'left'
|
||||
}
|
||||
board_line()
|
||||
|
||||
|
||||
class board_note_type(osv.osv):
|
||||
"""
|
||||
Board note Type
|
||||
"""
|
||||
_name = 'board.note.type'
|
||||
_description = "NOte Type"
|
||||
_columns = {
|
||||
'name': fields.char('Note Type', size=64, required=True),
|
||||
}
|
||||
|
@ -141,8 +164,13 @@ def _type_get(self, cr, uid, context={}):
|
|||
res = [(r['name'], r['name']) for r in res]
|
||||
return res
|
||||
|
||||
|
||||
class board_note(osv.osv):
|
||||
"""
|
||||
Board Note
|
||||
"""
|
||||
_name = 'board.note'
|
||||
_description = "Note"
|
||||
_columns = {
|
||||
'name': fields.char('Subject', size=128, required=True),
|
||||
'note': fields.text('Note'),
|
||||
|
@ -157,4 +185,3 @@ class board_note(osv.osv):
|
|||
board_note()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<menuitem icon="terp-graph" id="base.reporting_menu" name="Reporting" sequence="8"/>
|
||||
<!-- <menuitem icon="terp-graph" id="dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>-->
|
||||
<menuitem icon="terp-graph" id="base.reporting_menu"
|
||||
name="Reporting" sequence="8" />
|
||||
<!-- <menuitem icon="terp-graph" id="dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/>-->
|
||||
|
||||
<record id="view_board_note_tree" model="ir.ui.view">
|
||||
<field name="name">board.note.tree</field>
|
||||
<field name="model">board.note</field>
|
||||
|
@ -13,6 +15,9 @@
|
|||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--Board Note form -->
|
||||
|
||||
<record id="view_board_note_form" model="ir.ui.view">
|
||||
<field name="name">board.note.form</field>
|
||||
<field name="model">board.note</field>
|
||||
|
@ -27,6 +32,9 @@
|
|||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action for Publish note Form -->
|
||||
|
||||
<record id="action_view_board_note_form" model="ir.actions.act_window">
|
||||
<field name="name">Publish a note</field>
|
||||
<field name="res_model">board.note</field>
|
||||
|
@ -46,6 +54,9 @@
|
|||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Dashboard Definition form -->
|
||||
|
||||
<record id="view_board_form" model="ir.ui.view">
|
||||
<field name="name">board.board.form</field>
|
||||
<field name="model">board.board</field>
|
||||
|
@ -54,7 +65,10 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Dashboard">
|
||||
<field name="name" select="1"/>
|
||||
<button colspan="2" name="%(action_board_menu_create)d" string="Create Menu" type="action" icon="gtk-justify-fill"/>
|
||||
<button colspan="2"
|
||||
name="%(action_board_menu_create)d"
|
||||
string="Create Menu" type="action"
|
||||
icon="gtk-justify-fill" />
|
||||
<field colspan="4" name="line_ids">
|
||||
<tree string="Dashboard View">
|
||||
<field name="name"/>
|
||||
|
@ -67,19 +81,24 @@
|
|||
<field name="sequence"/>
|
||||
<field name="width"/>
|
||||
<field name="height"/>
|
||||
<field name="action_id" domain="[('view_type','!=','tree')]"/>
|
||||
<field name="action_id"
|
||||
domain="[('view_type','!=','tree')]" />
|
||||
<field name="position"/>
|
||||
</form>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action for DashBoard Definition form -->
|
||||
|
||||
<record id="action_view_board_list_form" model="ir.actions.act_window">
|
||||
<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
|
||||
id="base.next_id_50"
|
||||
name="Configuration"
|
||||
|
@ -90,10 +109,12 @@
|
|||
action="action_view_board_list_form"
|
||||
id="menu_view_board_form"
|
||||
parent="base.next_id_50" sequence="1"/>
|
||||
<menuitem action="action_view_board_note_form" id="menu_view_board_note_form" parent="base.next_id_50"
|
||||
sequence="3"
|
||||
groups="base.group_system" />
|
||||
<act_window context="{'view': active_id}" id="dashboard_open" multi="True" name="Open Dashboard" res_model="board.board" src_model="board.board"/>
|
||||
<menuitem action="action_view_board_note_form"
|
||||
id="menu_view_board_note_form" parent="base.next_id_50"
|
||||
sequence="3" groups="base.group_system" />
|
||||
<act_window context="{'view': active_id}" id="dashboard_open"
|
||||
multi="True" name="Open Dashboard" res_model="board.board"
|
||||
src_model="board.board" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -27,12 +27,15 @@ class board_menu_create(osv.osv_memory):
|
|||
Create Menu
|
||||
"""
|
||||
def check_views(self, cr, uid, context):
|
||||
board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
|
||||
if not board.line_ids:
|
||||
raise osv.except_osv(_('User Error!'), _('Please Insert Dashboard View(s) !'))
|
||||
return False
|
||||
|
||||
data = context and context.get('active_id', False) or False
|
||||
if data:
|
||||
board = self.pool.get('board.board').browse(cr, uid, data)
|
||||
if not board.line_ids:
|
||||
raise osv.except_osv(_('User Error!'), _('Please Insert Dashboard View(s) !'))
|
||||
return False
|
||||
|
||||
def board_menu_create(self, cr, uid, ids, context):
|
||||
def board_menu_create(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Create Menu.
|
||||
@param cr: the current row, from the database cursor,
|
||||
|
@ -40,22 +43,29 @@ class board_menu_create(osv.osv_memory):
|
|||
@param ids: List of Board Menu Create's IDs
|
||||
@return : Dictionary {}.
|
||||
"""
|
||||
board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
|
||||
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
|
||||
'name': board.name,
|
||||
'view_type':'form',
|
||||
'view_mode':'form',
|
||||
'res_model': 'board.board',
|
||||
'view_id': board.view_id.id,
|
||||
})
|
||||
if not context:
|
||||
context={}
|
||||
|
||||
context_id = context and context.get('active_id', False) or False
|
||||
if context_id:
|
||||
board = self.pool.get('board.board').browse(cr, uid, context_id)
|
||||
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
|
||||
'name': board.name,
|
||||
'view_type':'form',
|
||||
'view_mode':'form',
|
||||
'res_model': 'board.board',
|
||||
'view_id': board.view_id.id,
|
||||
})
|
||||
obj_menu = self.pool.get('ir.ui.menu')
|
||||
#start Loop
|
||||
for data in self.read(cr, uid, ids):
|
||||
self.pool.get('ir.ui.menu').create(cr, uid, {
|
||||
'name': data['menu_name'],
|
||||
'parent_id': data['menu_parent_id'],
|
||||
obj_menu.create(cr, uid, {
|
||||
'name': data.get('menu_name'),
|
||||
'parent_id': data.get('menu_parent_id'),
|
||||
'icon': 'STOCK_SELECT_COLOR',
|
||||
'action': 'ir.actions.act_window,'+str(action_id)
|
||||
}, context)
|
||||
|
||||
}, context=context)
|
||||
#End Loop
|
||||
return {}
|
||||
|
||||
_name = "board.menu.create"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--Board menu create wizard -->
|
||||
|
||||
<record id="view_board_menu_create" model="ir.ui.view">
|
||||
<field name="name">board.menu.create.form</field>
|
||||
<field name="model">board.menu.create</field>
|
||||
|
@ -14,13 +17,17 @@
|
|||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-save" string="Create Menu" name="board_menu_create" type="object"/>
|
||||
</group>
|
||||
<button icon="gtk-cancel" special="cancel"
|
||||
string="Cancel" />
|
||||
<button icon="gtk-save" string="Create Menu"
|
||||
name="board_menu_create" type="object" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action for Board Menu create wizard. -->
|
||||
|
||||
<record id="action_board_menu_create" model="ir.actions.act_window">
|
||||
<field name="name">Create Board Menu</field>
|
||||
<field name="res_model">board.menu.create</field>
|
||||
|
|
Loading…
Reference in New Issue