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

Hello,

I'm using Odoo 13 Community Edition on Windows.



The Onchange method:

@api.onchange('vorgang_auswahl')

    def _onchange_vorgang_auswahl(self):

        if self.vorgang_auswahl == 'gewinde':

            self.workcenter_id = 6


So if the user select the value "gewinde" from the selection field, the workcenter_id is directly "6", now i also want that if the user select "gewinde", the workcenter_id is "6" and the field should only show the ids "6" and "7". 


I already tried to use domain or something, but i failed.


Thanks in advance.

Avatar
Hylkää
Paras vastaus

Hi,

Please try the code below

@api.onchange('vorgang_auswahl')
def _onchange_vorgang_auswahl(self):
if self.vorgang_auswahl == 'gewinde':
self.workcenter_id = 6
    return {'domain': {'workcenter_id': [('id', 'in', [6, 7])]}}

Regards

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
heinäk. 19
6702
1
elok. 23
1848
2
heinäk. 22
11728
1
huhtik. 20
7367
1
tammik. 20
10560