跳至内容
菜单
此问题已终结
2 回复
40454 查看

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

形象
丢弃
最佳答案

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

形象
丢弃
最佳答案

my other fields trying add domain but not working

形象
丢弃
相关帖文 回复 查看 活动
2
4月 23
2772
2
11月 22
2850
1
2月 22
7866
2
12月 21
4132
0
10月 21
2266