diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 5f43f9c1bc7..795058c3ebd 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -222,17 +222,25 @@ class act_window(osv.osv): res[act.id] = str(form_arch) return res + def _get_help_status(self, cr, uid, ids, name, arg, context={}): + cr.execute(""" SELECT action.id, + CASE WHEN r.uid IS NULL THEN True ELSE False END + AS help_status FROM ir_act_window action + LEFT JOIN ir_act_window_user_rel r ON + (action.id = r.act_id AND (r.uid IS NULL or r.uid= %s)) WHERE action.id = ANY(%s)""",(uid,ids,)) + return dict(cr.fetchall()) + _columns = { 'name': fields.char('Action Name', size=64, translate=True), 'type': fields.char('Action Type', size=32, required=True), 'view_id': fields.many2one('ir.ui.view', 'View Ref.', ondelete='cascade'), - 'domain': fields.char('Domain Value', size=250, + 'domain': fields.char('Domain Value', size=250, help="Optional domain filtering of the destination data, as a Python expression"), - 'context': fields.char('Context Value', size=250, required=True, + 'context': fields.char('Context Value', size=250, required=True, help="Context dictionary as Python expression, empty by default (Default: {})"), - 'res_model': fields.char('Object', size=64, required=True, + 'res_model': fields.char('Object', size=64, required=True, help="Model name of the object to open in the view window"), - 'src_model': fields.char('Source Object', size=64, + 'src_model': fields.char('Source Object', size=64, help="Optional model name of the objects on which this action should be visible"), 'target': fields.selection([('current','Current Window'),('new','New Window')], 'Target Window'), 'view_type': fields.selection((('tree','Tree'),('form','Form')), string='View Type', required=True, @@ -253,8 +261,11 @@ class act_window(osv.osv): 'default_user_ids': fields.many2many('res.users', 'ir_act_window_user_rel', 'act_id', 'uid', 'Users'), 'search_view' : fields.function(_search_view, type='text', method=True, string='Search View'), 'menus': fields.char('Menus', size=4096), - 'help': fields.text('Action description', - help='Optional help text for the users with a description of the target view, such as its usage and purpose.') + 'help': fields.text('Action description', + help='Optional help text for the users with a description of the target view, such as its usage and purpose.'), + 'display_help':fields.function(_get_help_status, type='boolean', method=True, string='Display Help', + help='It gives the status if the help message has to be displayed or not when a user performs an action') + } _defaults = { 'type': lambda *a: 'ir.actions.act_window', @@ -266,6 +277,12 @@ class act_window(osv.osv): 'auto_refresh': lambda *a: 0, 'auto_search':lambda *a: True } + def _auto_init(self, cr, context={}): + super(act_window, self)._auto_init(cr, context) + cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'act_window_action_uid_index\'') + if not cr.fetchone(): + cr.execute('CREATE INDEX act_window_action_uid_index ON ir_act_window_user_rel (act_id, uid)') + cr.commit() act_window() class act_window_view(osv.osv):