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.

3

Passing values when returning a form [Closed]

By
Antanas
on 6/5/13, 5:00 AM 3,324 views

The Question has been closed

by
Sudhir Arya (SA)
on 06/07/2013 05:48:49

Hi,

If in wizard1 I have defined a method, which returns wizard2, how can I pass values from wizard1 to wizard2?

For example:

from osv import osv, fields

class SelectUser(osv.TransientModel):
    _name = 'select.user.wizard'
    _columns = {
        'user_id' = fields.many2one('res.users', 'User')
    }

    def call_another(self, cr, uid, ids, context=None):
        selection = self.read(cr, uid, ids, [], context=context)
        selection = selection[0]
        user_id = selection['user_id'][0]
        return {
            'type': 'ir.actions.act_window',
            'res_model': 'another.wizard',
            'view_mode': 'form',
            'view_type': 'form',
            'views': [(False, 'form')],
            'target': 'new',
         }

class AnotherWizard(osv.TransientModel):
    _name = 'another.wizard'
    _columns = {
        'user_id': fields.integer('User ID'),
        'something': fields.char('Something about him', size=60'),
    }

There in wizard 'select.user.wizard' method 'call_another' a user id is selected, and another wizard is called. How could I pass a user_id variable from one wizard to another?

6

You can pass any value in context when returning action.

Try this:

return {
       'type': 'ir.actions.act_window',
       'res_model': 'another.wizard',
       'view_mode': 'form',
       'view_type': 'form',
       'views': [(False, 'form')],
       'target': 'new',
       'context': context.update({'user_id': user_id})
}

Now you can access this context in any method of your another.wizard class like this:

usre_id = context.get('user_id', False)

Thank you.

Antanas
on 6/7/13, 4:44 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/5/13, 5:00 AM
Seen: 3324 times
Last updated: 3/16/15, 8:10 AM