This question has been flagged
1 Reply
5530 Views

How to redirect a view when clicking a button...

Avatar
Discard
Best Answer

Hi aci aisha,

You can use 2 ways of redirect a view from the button click.

1.       return {

                     'name' : 'Module name',

                      'view_type' : 'form',

                      'view_mode' : 'form',

                       'view_id': False,

                        'res_model' : 'res.partner',

                        'context' : context,

                        'type' : 'ir.actions.act_window',

                         'target' : 'current',

                     }

(or) 

2.       mod_obj = self.pool.get('ir.model.data')

           res = mod_obj.get_object_reference(cr, uid, 'res_partner', 'res_partner_form_view')

          res_id = res and res[1] or False

          return{ 

                    'name':'Module name',

                     'res_model':'res.partner',

                     'type': 'ir.actions.act_window',

                      'view_type': 'form',

                      'view_mode': 'form',

                       'view_id': [res_id],

                      'context':{},

                     'target':'new'

                       }

In xml_view:

<button name="method name"  type="object" />

Put that code in the return of the method.Hope it works..All the best

Avatar
Discard
Author

Thanks a lot Vasanth...

Author

But 1 problem,, When clicking the button i got a new window,, But there is no save button in that window... Can u help..

use 'target':'current'

Author

Thanks a lot my dear...

Author

Where are u from?

Pondicherry..India

Author

Hw r u

come to my personal email...vsnthajay@gmail.com