Files
tryton/dashboard.py
T

43 lines
1.6 KiB
Python
Raw Normal View History

2009-12-23 00:04:42 +01:00
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
2012-05-14 15:36:34 +02:00
from trytond.transaction import Transaction
from trytond.backend import TableHandler
2013-02-04 19:56:02 +01:00
from trytond.pyson import Eval
2009-12-23 00:04:42 +01:00
2012-09-24 22:17:54 +02:00
__all__ = ['DashboardAction']
2009-12-23 00:04:42 +01:00
class DashboardAction(ModelSQL, ModelView):
"Dashboard Action"
2012-09-24 22:17:54 +02:00
__name__ = "dashboard.action"
2009-12-23 00:04:42 +01:00
user = fields.Many2One('res.user', 'User', required=True,
2012-03-05 10:53:02 +01:00
select=True)
2012-05-14 15:36:34 +02:00
sequence = fields.Integer('Sequence',
order_field='(%(table)s.sequence IS NULL) %(order)s, '
'%(table)s.sequence %(order)s')
2009-12-23 00:04:42 +01:00
act_window = fields.Many2One('ir.action.act_window', 'Action',
required=True, ondelete='CASCADE', domain=[
2012-03-27 10:43:36 +02:00
('res_model', '!=', None),
('res_model', '!=', ''),
2013-02-04 19:56:02 +01:00
# XXX copy ir.action rule to prevent access rule error
['OR',
('groups', 'in', Eval('context', {}).get('groups', [])),
('groups', '=', None),
],
])
2009-12-23 00:04:42 +01:00
2012-09-24 22:17:54 +02:00
@classmethod
def __setup__(cls):
super(DashboardAction, cls).__setup__()
cls._order.insert(0, ('sequence', 'ASC'))
2009-12-23 00:04:42 +01:00
2012-09-24 22:17:54 +02:00
@classmethod
def __register__(cls, module_name):
2012-05-14 15:36:34 +02:00
cursor = Transaction().cursor
2012-09-24 22:17:54 +02:00
table = TableHandler(cursor, cls, module_name)
2012-05-14 15:36:34 +02:00
2012-09-24 22:17:54 +02:00
super(DashboardAction, cls).__register__(module_name)
2012-05-14 15:36:34 +02:00
# Migration from 2.4: drop required on sequence
table.not_null_action('sequence', action='remove')