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 ?
thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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 ?
thanks
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):
obj=self.pool.get('stock.location')
#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
rec.append(str(record['id']))
rec.append(record['shortcut'])
#agregamos a tupla final
res.append(tuple(rec))
#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.
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..