I'm working on 3 many2one fields in the 'res.partner' table: 'country_id', 'state_id' and 'city_id' and I want to use 'state_id.country_id' and 'city_id.state_id' in order to filter the value (all the states of a country, and all the cities of a state and none other) my question is : Is it possible to take the value of 'city_id.state_id' or 'state_id.country_id' and use it to filter the corresponding field ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
To add domain in the state_id field example,
'country_id': fields.many2one('res.country', 'Country'),
'state_id': fields.many2one("res.country.state", 'State', domain="[('country_id','=',country_id)]"),
You could create a related field to get to the country_id via state. You should then be able to set a domain on another field, based on the value of the related field.
Something like this (disclaimer: this is by head, can't check for errors):
country_id = fields.related('state_id', 'country_id', string="Related country")
"domain=[('country_id', '=', country_id)]"
Thank you very much prakash I had no idea I could do that with many2one fields, now it works perfectly.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký