Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to Disable button based on Condition ?

By
HappyOdoo
on 3/18/16, 4:02 AM 631 views

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?

     


0
Kinner Vachhani
On 3/18/16, 6:17 AM

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. 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/18/16, 4:02 AM
Seen: 631 times
Last updated: 3/18/16, 6:17 AM