This question has been flagged
2 Replies
31033 Views

hi all,

I want to add domain filter on field ( field2, field3 ), the filter is based on another Many2one field ( field3 is based on -> field2 is based on -> field1 )

for example: 

1) user select a value in field1 (will show all countries to select one)

2) field2 should be filtered as per field1 selected value  (filter to select states in selected country)

3) field3 should be filtered as per field2 selected value (filter to select cities in selected state)

please help.

regards

Avatar
Discard
Best Answer

Hi 
You can add a field as given below in the model for state (eg, res.country.state)

country_id = fields.Many2one('res.country', string='Country', required=True)

So that you can set the domain in for the field state_id as

state_id = fields.Many2one('res.country.state', string="State", domain="[('country_id', '=', country_id)]")

Similarly, you can add a field state_id in the model for city(eg: res.city) as,

state_id = fields.Many2one('res.country.state', 'State', domain="[('country_id', '=', country_id)]",required=True)

And you can set the domain in for the field city_id as

city_id = fields.Many2one('res.city', string="City", domain="[('state_id', '=', state_id)]")

Hope it helps

Avatar
Discard
Best Answer

my other fields trying add domain but not working

Avatar
Discard