Odoo Help


How to redirect to other view?

Juan Formoso
on 11/14/14, 10:42 AM 1,175 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?

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/14/14, 10:42 AM
Seen: 1175 times
Last updated: 3/16/15, 8:10 AM