Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
18945 Prikazi

I want to Disable button based on Condition.

I have two buttons. button 1 and button 2.

and condition for one text area field = field1.

field1 value like PO120, or SO250.

if field1 value PO then button 1 should to disable.

if field1 value SO then button 2 should to disable.

when form is open at that time we have to check what is the field1 value. 

How it's possible?

     


Avatar
Opusti
Best Answer

Best way I can think of is adding an invisible function field boolean on view. 

is_po = field.boolean(compute=_is_po)

@api.depends('field1') 
def _is_po_so(self):
    #your code
    self.is_po = False
========================
View
========================
<field name="is_po" invisible="1"/>
<button name="Button 1" attrs="{'invisible':[('is_po','=',True)]}" />

<button name="Button 1" attrs="{'invisible':[('is_po','=',False)]}" />

Check the above suedo code. 

Hope it helps. 

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
mar. 23
10593
2
mar. 23
2802
2
maj 22
4938
0
mar. 22
1851
1
maj 21
4757