summaryrefslogtreecommitdiff
path: root/addons/share/web/controllers.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2010-11-22 13:18:13 +0100
committerXavier Morel <xmo@openerp.com>2010-11-22 13:18:13 +0100
commitc8b4041d7078689d52ec684df71408455f75bd24 (patch)
tree74c575b05d56ad08dbad3e5e1d757aea8726636d /addons/share/web/controllers.py
parentfa3bda7f54979813105ff472a55d26e5b17dfa12 (diff)
[IMP] action: formatting of ShareWizardController.index, bail out early to reduce nesting
bzr revid: xmo@openerp.com-20101122121813-ih6qf4d5jrif914d
Diffstat (limited to 'addons/share/web/controllers.py')
-rw-r--r--addons/share/web/controllers.py42
1 files changed, 29 insertions, 13 deletions
diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py
index 2f6c8d4cfc8..b6ecb186758 100644
--- a/addons/share/web/controllers.py
+++ b/addons/share/web/controllers.py
@@ -12,19 +12,35 @@ class ShareWizardController(openerp.controllers.SecuredController):
@expose()
def index(self, domain, search_domain, context, name):
+ context = ast.literal_eval(context)
+ view_name = context.get('_terp_view_name') or name
+ if not view_name: return
+
+ action_id = rpc.RPCProxy('ir.actions.actions').search(
+ [('name','=',view_name)], 0, 0, 0, context)
+ if not action_id: return
+
domain = ast.literal_eval(domain)
search_domain = ast.literal_eval(search_domain)
domain.extend(search_domain)
- context = ast.literal_eval(context)
- view_name = context.get('_terp_view_name') or name
- if view_name:
- action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context)
- if action_id:
- action_id = action_id[0]
- share_model = 'share.wizard'
- share_root_url = cherrypy.request.base
-
- share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')])
- context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard', 'share_root_url': share_root_url})
- sharing_view_id = rpc.RPCProxy(share_model).create({'domain': str(domain), 'action_id':action_id}, context)
- return actions.execute(rpc.session.execute('object', 'execute', share_model, 'go_step_1', [sharing_view_id], context), ids=[sharing_view_id], context=context)
+
+ action_id = action_id[0]
+ share_model = 'share.wizard'
+ share_root_url = cherrypy.request.base
+
+ share_wiz_id = rpc.RPCProxy('ir.ui.menu').search(
+ [('name','=', 'Share Wizard')])
+ context.update({
+ 'active_ids': share_wiz_id,
+ 'active_id': share_wiz_id[0],
+ '_terp_view_name': 'Share Wizard',
+ 'share_root_url': share_root_url
+ })
+ sharing_view_id = rpc.RPCProxy(share_model).create({
+ 'domain': str(domain),
+ 'action_id':action_id
+ }, context)
+ return actions.execute(
+ rpc.session.execute('object', 'execute', share_model, 'go_step_1',
+ [sharing_view_id], context),
+ ids=[sharing_view_id], context=context)