Odoo Help

0

button to redirect to another form

By
daouda
on 2/24/14, 7:10 PM 4,185 views

Hi, I have a form view in Openerp and i have a button which redirect to another form. I want wehn clicked to the button, amany2one field to be filled by the id of the current object. Thanks for your help

0
Maniganda
On 2/25/14, 8:38 AM

If you want automatically to fill the many2one field then create a button of type object and in the function ctx.update({ 'default_model':'your.model', 'default_many2one_field': ids[0], }) return { 'type': 'ir.actions.act_window', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'mail.compose.message', 'views': [(compose_form_id, 'form')], 'view_id': compose_form_id, 'target': 'new', 'context': ctx, }

In this mehod you should update the context with the default value for your many2one field and pass it in the return method of your function, this will redirect to the view which you specify and load with the value for many2one which you have passed.

for furthur reference check for "action_quotation_send" in sale.py file

Thanks a lot it works.

daouda
on 2/25/14, 10:22 AM
0
Ashif Abdulrahman
On 2/25/14, 8:42 AM

do a function like this

    obj_model = self.pool.get('ir.model.data')
    model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_automatic_reconcile_view1')])
    resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
    return {
                    'name': 'Customer Invoices',
                    'view_type': 'form',
                    'view_mode': 'form',
                    'view_id': [res_id],
                    'res_model': 'account.invoice',
                    'context': "{'type': 'out_invoice'}",
                    'type': 'ir.actions.act_window',
                    'nodestroy': True,
                    'target': 'current',
                    'res_id': inv_id or False,
                   }

will you please explain what is the use of 'nodestroy'

Janarthanan
on 7/5/16, 6:21 AM

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 2/24/14, 7:10 PM
Seen: 4185 times
Last updated: 3/16/15, 8:10 AM