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

Hello,

I need to change my slection elements after change field1 .

this code doesn't work , who has an idea how to fix it ?

_columns = {

'field1': fields.selection([('1', 'A'), ('1', 'B')], 'my filed 1'),

'field2': fields.selection([('aa', 'C'), ('bb', 'D')], 'my filed 2'),

}

def onchange_field2(self, cr, uid, ids,field1,context=None):

    lst= [('5', '5'), ('6', '6'), ('7', '7'), ('8', '8')]

    try:

        lst.remove([item for item in lst if item[0] == '5'][0])

    except IndexError as e:

        pass

    v = {'field2': lst}

    return {'value': v}

thank you

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

Yes you can not change using onchage of selection field value. It the collection of static value. you only used those value for selection which you had been define while creating selection field.

Thank you.

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

Sorry but selection fields doesn't allow you to change the values like you are doing, they are a kind of static collection of options/values to select just one. For doing something like that you need to change your field definition to a many2one and apply a domain to the field that restrict the results to the matching records and the domain could be build and returned from an onchange

อวตาร
ละทิ้ง

Hola Axel, una duda, estoy intentando poner un campo Selection, pero que cambie sus "valores" de acuerdo a un campo seleccionado como la periodicidad. Entiendo por lo que escribes que no es posible debido a que es una colección de valores fijos, se obtienen antes de "dibujar" la forma. Pero entonces, ¿no es posible "redibujar" ese campo en particular cuando mi otro campo cambie?

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 23
5069
onChange event selection แก้ไขแล้ว
2
มิ.ย. 20
9605
1
มี.ค. 15
4704
2
ก.ย. 23
8962
4
ธ.ค. 23
22406