Odoo Help

Welcome!

This community 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.

0

How to redirect to other view?

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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