Odoo Help


When changing the value of this combobox, the data will show the other combobox in openerp

lam a bao
on 11/21/13, 5:12 AM 2,830 views

Hi everyone

I have two combobox_A and combobox_B .When i change value of combobox_A ,data will show combobox_B

How do I? can you hepl me ?


Vitap ramdevputra
On 11/21/13, 5:48 AM

Hello lam,

while creating model, you have to keep the column type of " combobox_B" as many2one(), and also in many2one you have to specify optional parameter "domain". Here is the example how to use domain.

_columns = { 'x_combobox_B' : fields.many2one('nameofmodule','B(caption)', domain="[('id','=',combobox_A_id)]")}

Hope it helps you..

wilson zauma
On 4/4/14, 5:53 PM

In my XML, put this field :

<field name="aux_almacen_orig" on_change="onchange_almacen_aux_id(aux_almacen_orig)" />

and my_file.py

def _buscar_shortname_alm(self, cr, uid, context=None):

        #ids = obj.search(cr, uid, [('shortcut', '!=', False),('usage','in',('internal','production'))],
        #    order='shortcut') 
        ids = obj.search(cr, uid, [('shortcut', '!=', False)], order='shortcut') 
        #print "\n ---- demo con browse Ids ---------------------------\n",ids
        # devuelve lista [12, 11, 7, 21, 20]

        resultado = obj.read(cr, uid, ids, ['id','shortcut'], context)
        #print "\n ---- demo con browse resultado ---------------------------\n",resultado
        #devuelve Lista de diccionarios ejemplo: [{'id': 11, 'shortcut': u'Almacen Principal - Salida'}, {'id': 7, 'shortcut': u'Produccion'}]

        #convertimos a una lista de tuplas
        res = []
        for record in resultado:
            #creamos la tupla interna
            rec = []
            #convertimos a cadena el ID para crear la tupla
            #agregamos a tupla final
        #print "\n ---- demo con browse res ---------------------------\n",res
        # devuelve lista de tuplas : [('11', 'Almacen Principal - Salida'), ('7','Produccion')]
        return res

_columns = {
'aux_almacen_orig': fields.selection(_buscar_shortname_alm, type="char",store=True, method=True,size=256, required=True, string="Almacen Origen" ),

def onchange_almacen_aux_id(self, cr, uid, ids, location_id, context=None):
    global globa_id_almacen_origen
    values = {}
    #asigno la variable global a usar en los detalles de doc de venta y llenado automatico
    # convierto la cadena que es el index seleccionado a un entero
    globa_id_almacen_origen = int(location_id)
    #asignamos al campo XML [location_id] el valor del ID seleccionado - sincroniza el campo
    values['location_id'] = int(location_id)
    return {'value': values }

This works for me. and when i select in combo one, automaty select the same in combo two. i wait for your commets.

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.


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)


Asked: 11/21/13, 5:12 AM
Seen: 2830 times
Last updated: 3/16/15, 8:10 AM