在odoo中单击一次后如何更改按钮的颜色并使其禁用?

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

我正在通过单击 邀请 按钮向用户发送邀请。我希望在发送邀请按钮后不可点击并且它的颜色也会改变。

您可以根据条件隐藏该按钮。

例如,如果您有两个状态 draft,invitation_sent,默认情况下表单将以草稿状态打开。单击按钮后,将状态更改为 invitation_sent。并在inivtation_sent状态下隐藏按钮。

代码示例:

在Python中:

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

在XML中:

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