Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
3505 Näkymät

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


Avatar
Hylkää
Tekijä Paras vastaus

I fix this problem with this domain: 

* you need to use this word "parent" 

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

that's it 

thank you

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
elok. 19
2548
1
syysk. 17
5503
1
maalisk. 23
2461
0
jouluk. 22
3109
1
lokak. 22
3950