Redirecting to another form in OpenERP

If you want to redirect to another object when an event occurs like click of a button, then you just need to return dictionary having the following syntax-
return {
‘name’:_(“Name of the form”),
‘view_mode’: ‘form’,
‘view_id’: False,
‘views’: [(resource_id,’form’)],
‘view_type’: ‘form’,
‘res_id’ : res_id, # id of the object to which to redirected
‘res_model’: ‘stock.picking’, # object name
‘type’: ‘ir.actions.act_window’,
‘target’: ‘new’, # if you want to open the form in new tab

10 thoughts on “Redirecting to another form in OpenERP

  1. Dado

    Thank you for blog. I need to execute some python code on event click on button, but not redirect to another object. Is it possible and how?


    1. For that you need to declare button as type=object. Like as follows-

      And in .py file you need to define function create_moves
      def create_moves(self, cr, uid, ids, context={}):
      //Python code

      1. Dado

        Thanks for answer. I forgot to clearly describe problem. I have two buttons: one button which comes with instalation () and one created with your advices.
        My problem is how integrate this two buttons into one with same functionlities: validate invoice and execute code in function create_moves.


  2. Dado

    Missing part between brackets is from file account_invoice_view.xml :
    button name=”invoice_open” states=”draft,proforma2″ string=”Validate” icon=”gtk-go-forward”

    1. button invoice_open is used as an event to move from one activity to another. If you want to execute any code, the best way is to call the function at the destination activity. Or you can describe the button as type=object and write the code there.
      So, in your case, you need to inherit the view and just replace the button invoice_open with type=object. And define the function def invoice_open() in .py file.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s