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

button to redirect to another form

By
daouda
on 2/24/14, 7:10 PM 3,133 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

--Maniganda--
1038
| 5 7 7
Bangalore, India
--Maniganda--
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

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

0 follower(s)

Stats

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