Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
2929 Переглядів

Hello,

​I'm currently  working on a custom module in wich i'd like to modify 2 domains if an other is change. It look like this:

​@api.onchange('field_1')    
def onchange_partner_id(self):       
​for rec in self:
            ​return {'domain': {'field_2': [('parent_id', '=', rec.field_1.id)]}},{'field_3': [('parent_id', '=', rec.field_1.id)]} 

If it's not possible, please tell me if they're is an other way to do so, otherwise thank you for your answers !

Have a nice day,

Ewen JEZEQUEL

Аватар
Відмінити
Найкраща відповідь

Hi,

The code you provided contains a syntax error where you have two separate dictionary objects.

Here is the corrected code:


@api.onchange('field_1')

def onchange_partner_id(self):

    for rec in self:

        return {'domain': {'field_2': [('parent_id', '=', rec.field_1.id)],

                           'field_3': [('parent_id', '=', rec.field_1.id)]}}


Hope it helps

Аватар
Відмінити
Найкраща відповідь

Hi, 

You can watch following video for this:

https://youtu.be/ezH3ql5Dmx4

Thanks

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
черв. 15
4989
when i use @api.model? Вирішено
3
лист. 24
17823
1
лист. 22
3124
2
груд. 19
8173
1
бер. 19
3593