大多数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)
因此,如果您准备好了一个按钮更改其值的字段,您可以直接使用它或为此创建一个特殊字段.
归档时间: |
|
查看次数: |
719 次 |
最近记录: |