From c8b4041d7078689d52ec684df71408455f75bd24 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 22 Nov 2010 13:18:13 +0100 Subject: [PATCH] [IMP] action: formatting of ShareWizardController.index, bail out early to reduce nesting bzr revid: xmo@openerp.com-20101122121813-ih6qf4d5jrif914d --- addons/share/web/controllers.py | 40 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 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)