Search code examples
buttoncolorsformattingodoodisable

How to change the color of the button and make it disable after clicking once in odoo?


I am sending invitation to user by clicking Invite button. I want that after sending invitation button should un-clickable and its color also change.


Solution

  • You can hide that button with conditions.

    For example, if you have two states draft,invitation_sent, by default the form will open in draft state. Once you click the button, change the state to invitation_sent. And hide the button in the inivtation_sent state.

    Code example:

    In Python:

    def invite(self):
        ````````````````````````````````
        ````````````````````````````````
        ````````````````````````````````
        self.write({'state': 'inivtation_sent'})
    

    In XML:

    <button name="invite" type="object" string="Invite" class="oe_highlight" attrs="{'invisible':[('state','=','inivtation_sent')]}"/>