Odoo Help


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.


Two selection fields, second selection depends on the first selected value

on 12/13/15, 8:20 AM 406 views

I have a wizard model, where user can choose a car from another model(named 'techdoc' with fields car brand, model, year etc).
In first selection field user chooses car brand, and in second selection user chooses car model, depends on the selected first field.
But the second field value does not displays computed values to choose after setting the second field value. 
Is there any method to make it work properly?

class Roll_wizard(models.TransientModel):

_name = 'roll.wizard'


def get_car_brand(self):

brand = []

result = self.env['techdoc'].search([('name', '!=', "")])

for record in result:

tup=(record.name.lower(), record.name.title())


brand = list(set(brand))

return sorted(brand)


def ret_value(self):

return self.car_brand


def get_car_model(self):

model = []

result = self.env['techdoc'].search([('name', '=', self.ret_value)])

for record in result:

tup=(record.car_model, record.car_model.title())


model = list(set(model))

return sorted(model)

car_brand = fields.Selection(get_car_brand, string="Car Brand")

car_model = fields.Selection(get_car_model, string="Car Model")


If I'll print in console the result of returned value's of get_car_model:

print result

print model

techdoc(18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32)

[(u'fiesta', u'Fiesta'), (u'focus', u'Focus'), (u'fusion', u'Fusion')]

 So we can see, server returns the right value, but the selection field is not updated dynamically. 

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

1 follower(s)


Asked: 12/13/15, 8:20 AM
Seen: 406 times
Last updated: 12/15/15, 3:28 PM