This question has been flagged
4914 Views

I created a function (in res.partner model) which does some things and after that redirects to other view of other different model (event.event). Here is the code:

wiz_data = self.read(cr, uid, ids)[-1]
datas = {
    'event_id': wiz_data.get('event') and wiz_data['event'][0] or None,
    'event_name': wiz_data.get('event') and wiz_data['event'][1] or None,
}

data_obj = self.pool.get('ir.model.data')
tree_data_id = data_obj._get_id(cr, uid, 'event', 'view_event_tree')
form_data_id = data_obj._get_id(cr, uid, 'event', 'view_event_form')
tree_view_id = False
form_view_id = False
if tree_data_id:
    tree_view_id = data_obj.browse(cr, uid, tree_data_id, context=context).res_id
if form_data_id:
    form_view_id = data_obj.browse(cr, uid, form_data_id, context=context).res_id

return {
    'view_type': 'form',
    'view_mode': 'form',
    'view_id': [datas['event_id'] or False],
    'views': [(tree_view_id, 'tree'), (form_view_id, 'form'),],
    'res_model': 'event.event',
    'type': 'ir.actions.act_window',
    'nodestroy': True,
    'target': 'current',
    'flags': {'tree': {'action_buttons': True},
              'form': {'action_buttons': True},} 
}

With that return, the form and tree I want are opened, but the menu which appears on the left (out of the view) belongs to the old model (res.partner), and on the top menu the option Clients is selected. I would like to redirect to the view of an event, with its own left menu and seeing the option Events selected on the top menu.

How can I redirect to the whole page of events?

Avatar
Discard