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

Hi,


when I set a field with a value, depending on an x condition, my field becomes invisible. I'd like to know if there's an “ODOO” method for clearing this field when it becomes invisible. Because this leads to functional problems where unwanted information ends up being taken into account?


thanks

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

Hi Loïc

you can add an @api.onchange or @api.depends on you method, that handle if the field is visible and unset the value if the condition are not met

example

field_is_visible = fields.Boolean()

my_field = fields.Text()

@api.depends('field_x1','field_x1' ) 
def _check_visibility(self):
for rec in self:
​if #your condition:
​rec.field_is_visible = true
​else:
​rec.field_is_visible = False
rec.my_field = False # or '' depending on your fields type​


 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Hi Jainil, 

thanks for your answer. 

i understand that the framework does not offer an automated solution. 

bye

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

Hello Loic,

you have one field which is having some condition on which the field is being invisible, so on that condition you need to have an function which will make the field empty which will make the non needed value stored in the field thus you want to empty it. 

do i convey your need properly respond me so i can take you further with the solution.

Thanks


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ต.ค. 25
3
2
ต.ค. 25
5213
Delivery Note Management แก้ไขแล้ว
2
ต.ค. 25
421
POS receipt template V19 แก้ไขแล้ว
2
ต.ค. 25
490
1
ต.ค. 25
487