如何在第一次点击后禁用按钮?

Gue*_*smi 1 openerp odoo-10

这可能是一个简单的问题.但是,任何人都知道如何在Odoo中单击它后禁用按钮吗?感谢你的帮助.

Cha*_* DZ 5

大多数Odoo模块都使用状态来解决这类问题.一般的想法是你必须有一个字段,并根据该字段的值显示按钮.

例如:

  # in you model
  bool_field = fields.Boolean('Same text', default=False)
Run Code Online (Sandbox Code Playgroud)

在你看来:

 <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"/>
Run Code Online (Sandbox Code Playgroud)

在你的模型中:

 @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
    ...
    ...
    ...
Run Code Online (Sandbox Code Playgroud)

因此,如果您准备好了一个按钮更改其值的字段,您可以直接使用它或为此创建一个特殊字段.