Reputation: 11
I have started working on Odoo 10 recently. I need to customize form and tree views.
For example
Open a new form view when clicking on a button in a tree view.
Also, I want a different form view which comes as a result of saved record.
Kindly guide me.
Upvotes: 0
Views: 779
Reputation: 319
Hello this answer is for your first case that is Open a new form view when clicking on a button in tree view
Try returning something like this - Calling method on button click
@api.multi
def my_method(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'model_name',
'view_type': 'form', #to redirect to form view
'view_mode': 'form',
'target': 'new',
}
Upvotes: 3
Reputation: 275
Hello, this answer is for your Second case that is you also want a different form view which comes as a result of saved record.
@api.multi
def my_method(self):
return {
'type': 'ir.actions.act_window',
'res_model': 'model_name',
'view_type': 'form', #to redirect to form view
'view_mode': 'form',
'target': 'new',
'res_id': record.id
}
Upvotes: 0