Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3497 Lượt xem

Hello everyone,

i need to add a domian in Many2one field that exist in One2many Field 

###### country Model ####

country= fields.Char(string=" country ")


##### city Model ###

country _ids = fields.Many2one(comodel_name='  country ')

city = fields.Char(string="City")

###### Visit Model ####

visit =  fields.Char(string="Visit")

city_ids = fields.Many2one(comodel_name=' city ')

#######

let's suppose that i have this data:

country: USA, SPAIN, ITALIE

city: 

[USA: NEW YOUR, MIAMI,Colorado ]

[SPAIN: MADRID, BARCALONE]

[ITALIE: ROMA, NAPOLI]

#######

###### visit planning #####

date =   fields.Date(string="Visit")

country =  fields.Many2one(comodel_name='  country ')

city =  fields.One2many(comodel_name='  city ')


so i want at this point that when i select a country for Example SPAIN

i want to see only   MADRID and BARCALONE in my One2many field


how can i do that and thank you


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I fix this problem with this domain: 

* you need to use this word "parent" 

domain="[('country','=',parent. country )]"

that's it 

thank you

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 19
2545
1
thg 9 17
5495
1
thg 3 23
2447
0
thg 12 22
3092
1
thg 10 22
3942