如何根据另一个模块中的状态隐藏 account.invoice 中的验证按钮?
How can I hide Validate button in account.invoice based on state in another module?
我需要根据存在于另一个具有财务结算状态的模块中的状态选择字段隐藏 account.invoice 中的验证按钮。
如果状态为 financial_close
,则隐藏验证按钮
<button name="invoice_open" states="draft" string="Validate" class="oe_highlight" groups="base.group_user"/>
另一个包含财务结算状态的模块
'status': fields.selection([
('open', 'Open'),
('operation_close', 'Operation Closed'),
('financial_close', 'Financial Closed'),
('cancel', 'Cancel'),
], string="Status"),
执行以下步骤:
- 使用 另一个模块 在
account.invoice
中创建 Many2one
。
- 在
account.invoice
中创建一个相关字段 mystatus
,其中 Many2one
之前已创建。
- 继承invoice_open的父视图[
invoice_form
]。
- 将您的相关字段:
mystatus
放在视图上 Like:<field name="mystatus"/>
。
- 使用
xpath
和postion= attributes
这是代码片段:
<xpath expr="//button[@name='invoice_open']" position="attributes">
<attribute name="attrs">{'invisible':[('mystatus','=', 'open')]}</attribute>
这可能对您的情况有所帮助
我需要根据存在于另一个具有财务结算状态的模块中的状态选择字段隐藏 account.invoice 中的验证按钮。
如果状态为 financial_close
,则隐藏验证按钮<button name="invoice_open" states="draft" string="Validate" class="oe_highlight" groups="base.group_user"/>
另一个包含财务结算状态的模块
'status': fields.selection([
('open', 'Open'),
('operation_close', 'Operation Closed'),
('financial_close', 'Financial Closed'),
('cancel', 'Cancel'),
], string="Status"),
执行以下步骤:
- 使用 另一个模块 在
account.invoice
中创建Many2one
。 - 在
account.invoice
中创建一个相关字段mystatus
,其中Many2one
之前已创建。 - 继承invoice_open的父视图[
invoice_form
]。 - 将您的相关字段:
mystatus
放在视图上 Like:<field name="mystatus"/>
。 - 使用
xpath
和postion= attributes
这是代码片段:
<xpath expr="//button[@name='invoice_open']" position="attributes">
<attribute name="attrs">{'invisible':[('mystatus','=', 'open')]}</attribute>
这可能对您的情况有所帮助