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

Odoo redirect to another form on "Create" button click

By
ahmed khakwani
on 5/27/16, 7:19 AM 621 views

How can i redirect to other model form view on "Create" button click. I tries that using "view_init", and try to return model name etc, but it didn't work. I tried that code 


def view_init(self, cr, uid, fields_list, context=None):
return {
'name': _('Patient Group Lab Test Form'),
'view_mode': 'form',
'view_id': False,
'view_type': 'form',
'res_model': 'oeh.group.lab.test',
'type': 'ir.actions.act_window',
'target': 'self',
}

Currently i am on that model "oeh.medical.radiology.report", and i need to open "oeh.group.lab.test" form view on create button click.

Come on odoo developers plz help me, am badly stuck in it


0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 5/30/16, 2:42 AM

ahmed,

What you can do is,

in create method only, call its super and then return this :

return {  
     'name': _('Patient Group Lab Test Form'),
    'view_mode': 'form',
    'view_id': False,
    'view_type': 'form', 
   'res_model': 'oeh.group.lab.test',
    'type': 'ir.actions.act_window',
    'target': 'self',
}

But before returning this, you have to commit the changes you have done, as odoo expects new record id from create method as a return statement, but we are going to return an action....

So use : cr.commit() before returning above lines....

Hope this Help you....

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

2 follower(s)

Stats

Asked: 5/27/16, 7:19 AM
Seen: 621 times
Last updated: 5/30/16, 2:42 AM