如何在第一次点击后禁用按钮?
how to disable a BUTTON after first click?
这可能是一个简单的 question.but,有谁知道如何在 Odoo 中单击按钮后禁用它吗?感谢您的帮助。
大多数 Odoo 模块都使用状态来解决此类问题。它的一般想法是您必须有一个字段,并且根据该字段的值显示按钮。
例如:
# in you model
bool_field = fields.Boolean('Same text', default=False)
在您看来:
<button name="some_method"......... attrs="{'invisible': [('bool_field', '=', True)]}" />
...
...
...
<!-- keep the field invisible because i don't need the user to see
it, the value of this field is for technical purpuse -->
<field name="bool_field" invisible="1"/>
在您的模型中:
@api.multi
def some_method(self):
# in this method i will make sure to change the value of the
# field to True so the button is not visible any more for user
self.bool_field = True
...
...
...
因此,如果您已经准备好一个按钮可以更改其值的字段,您可以直接使用它
或为此创建一个特殊字段。
这可能是一个简单的 question.but,有谁知道如何在 Odoo 中单击按钮后禁用它吗?感谢您的帮助。
大多数 Odoo 模块都使用状态来解决此类问题。它的一般想法是您必须有一个字段,并且根据该字段的值显示按钮。
例如:
# in you model
bool_field = fields.Boolean('Same text', default=False)
在您看来:
<button name="some_method"......... attrs="{'invisible': [('bool_field', '=', True)]}" />
...
...
...
<!-- keep the field invisible because i don't need the user to see
it, the value of this field is for technical purpuse -->
<field name="bool_field" invisible="1"/>
在您的模型中:
@api.multi
def some_method(self):
# in this method i will make sure to change the value of the
# field to True so the button is not visible any more for user
self.bool_field = True
...
...
...
因此,如果您已经准备好一个按钮可以更改其值的字段,您可以直接使用它 或为此创建一个特殊字段。