Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6428 มุมมอง

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)?


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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...

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Text after the field in a form แก้ไขแล้ว
2
ธ.ค. 23
17605
1
มี.ค. 15
6041
3
ส.ค. 23
7028
2
พ.ค. 16
8955
2
ม.ค. 16
5253