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

Hi, I would like to know if it's possible to do the following

Only show a field for example

myField = fields.Text(string="My Field")

When and option on my field many2many is selected,

fieldm2m = fields.Many2many('info.information')

I want to show the text field when the option OTHERS is selected on the many2many field

On the CSV is like this

id, codigo

1,GOOD

2,BAD

3,OTHERS

Thank you for your help

อวตาร
ละทิ้ง

Hope this will contain your query: https://goo.gl/8HgnCF

คำตอบที่ดีที่สุด

You can create a Boolean field compute that verify if a record was checked in your many2many. Then you make a condition based on your Boolean field for the visibility of myField.

Something like this:

is_visible = fields.Boolean(compute='_compute_visibility')
@api.depends('fieldm2m')
def _compute_visibility(self):
    for rec in self:
        rec.is_visible = bool(rec.fieldm2m)
In your xml:
<field name="is_visible" invisible="1"/>
<field name="myField" attrs="{'invisible': [('is_visible', '=', False)]}"/>
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 21
5387
3
ก.ค. 19
6664
0
ส.ค. 18
2414
0
พ.ค. 16
6108
2
มี.ค. 15
8818