Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
6320 Zobrazení

I was wondering how to set field attributes (invisible, readonly, domain, ...) in form via @api.onchange (as it was returning the attributes from the method in v7)?


Avatar
Zrušit
Nejlepší odpověď

Hi Nedas,

   Right now in onchange no need to return anything(in new api), but there is a case when we want to return some warning, domain or other stuff. So, in this case we can return as old api style like.

--------------------------------------------------

@api.onchange('my_field')

def onchange_my_field(self):

     msg={}

     self.my_other_field = self.my_field #Here just copy whatever come with my_field into my_other_field

     if (self.warning==True):

         msg = { 'title': _('Waning!'), 'message' : 'You have just copy my field into my other field...'

                         }

   return {'warning': msg}

-----------------------------------------------         

same way we can return other stuff.

Hope this will help u as u want...

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
pro 23
17452
1
bře 15
5917
3
srp 23
6889
2
kvě 16
8783
2
led 16
5122