From c9ace81dbe3390276715d0e28c79eb5f702c077f Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Fri, 2 Jul 2010 17:53:46 +0530 Subject: [PATCH 1/5] [Add]:added display_help for menu when user clicks first time bzr revid: nch@tinyerp.com-20100702122346-d59samoc6lq4mesj --- bin/addons/base/ir/ir_actions.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 4cbce73eff8..a6354f339f2 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -222,6 +222,15 @@ class act_window(osv.osv): res[act.id] = str(form_arch) return res + def _get_help_status(self, cr, uid, ids, name, arg, context={}): + res = {} + for action in self.browse(cr, uid, ids): + res[action.id] = True + user_ids = map(lambda x:x.id, action.default_user_ids) + if uid in user_ids: + res[action.id] = False + return res + _columns = { 'name': fields.char('Action Name', size=64, translate=True), 'type': fields.char('Action Type', size=32, required=True), @@ -247,7 +256,8 @@ 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': fields.text('Action description'), + 'display_help':fields.function(_get_help_status, type='boolean', method=True, string='Display Help') } _defaults = { 'type': lambda *a: 'ir.actions.act_window', From a846db1e2e738eb5cde927d467fe5a9fe2b6e5bb Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Tue, 6 Jul 2010 12:33:06 +0530 Subject: [PATCH 2/5] [IMP]:help getting bzr revid: nch@tinyerp.com-20100706070306-fv39hzi2ov43w6fv --- bin/addons/base/ir/ir_actions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index a6354f339f2..a5dfb25d666 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -223,6 +223,13 @@ class act_window(osv.osv): return res def _get_help_status(self, cr, uid, ids, name, arg, context={}): +# cr.execute('select uid from ir_act_window_user_rel where act_id=ANY(%s)',(ids,)) +# user_ids = map(lambda x:x[0],cr.fetchall()) +# res = {} +# for action in ids: +# res[action] = True +# if uid in user_ids: +# res[action] = False res = {} for action in self.browse(cr, uid, ids): res[action.id] = True From c4cddcd400d7cb6c5231c8575caa25a39913d6d9 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Tue, 6 Jul 2010 15:58:12 +0530 Subject: [PATCH 3/5] [IMP]:performance issues bzr revid: nch@tinyerp.com-20100706102812-xf1j6jixhefukogr --- bin/addons/base/ir/ir_actions.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 8cd7835bf47..2fecf0476b7 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -223,20 +223,12 @@ class act_window(osv.osv): return res def _get_help_status(self, cr, uid, ids, name, arg, context={}): -# cr.execute('select uid from ir_act_window_user_rel where act_id=ANY(%s)',(ids,)) -# user_ids = map(lambda x:x[0],cr.fetchall()) -# res = {} -# for action in ids: -# res[action] = True -# if uid in user_ids: -# res[action] = False - res = {} - for action in self.browse(cr, uid, ids): - res[action.id] = True - user_ids = map(lambda x:x.id, action.default_user_ids) - if uid in user_ids: - res[action.id] = False - return res + 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), @@ -284,6 +276,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): From 9f934045f38d1f14bd5bda514b363b94bc0fea98 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Tue, 6 Jul 2010 17:13:32 +0530 Subject: [PATCH 4/5] [IMP]:syntax repr bzr revid: nch@tinyerp.com-20100706114332-85ex6g6oil99c90u --- bin/addons/base/ir/ir_actions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 2fecf0476b7..27d4f0ddc00 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -223,10 +223,10 @@ class act_window(osv.osv): 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 + 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()) From 81459f756fb1a9637201efc20c991e28b42bd074 Mon Sep 17 00:00:00 2001 From: "nch@tinyerp.com" <> Date: Tue, 6 Jul 2010 18:59:39 +0530 Subject: [PATCH 5/5] [IMP]:added help for display_help field bzr revid: nch@tinyerp.com-20100706132939-zk26ina612byz87m --- bin/addons/base/ir/ir_actions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py index 27d4f0ddc00..795058c3ebd 100644 --- a/bin/addons/base/ir/ir_actions.py +++ b/bin/addons/base/ir/ir_actions.py @@ -263,7 +263,8 @@ class act_window(osv.osv): '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.'), - 'display_help':fields.function(_get_help_status, type='boolean', method=True, string='Display Help') + '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 = {