majid
majid

Reputation: 11

How to customize Views in Odoo

I have started working on Odoo 10 recently. I need to customize form and tree views.

For example

  1. Open a new form view when clicking on a button in a tree view.

  2. Also, I want a different form view which comes as a result of saved record.

Kindly guide me.

Upvotes: 0

Views: 779

Answers (2)

Shikhar S
Shikhar S

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

Ravi Bhateliya
Ravi Bhateliya

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

Related Questions