javascript - 如何使现有按钮仅对特定组不可见。奥多 14
问题描述
我想让模型“account.move”中的“Reset To Draft”按钮仅对“account.group_account_invoice”可见,这意味着,对于组“account.group_account_manager”应该是不可见的,这是我的代码;
<record id="account_move_form_view_extend" model="ir.ui.view">
<field name="name">account.move.form.view.extend</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//header//button[@name='button_draft']" position="attributes"/>
<attribute name="groups">account.group_account_manager</attribute><xpath/>
<attribute name ="attrs=">{'invisible' : [('show_reset_to_draft_button', '=', True)]}</attribute>
</field>
</record>
但我收到了这个错误:
raise ValueError(formatted_message).with_traceback(from_traceback) from from_exception
odoo.exceptions.ValidationError: Error while validating view:
Element '<attribute name="groups">' cannot be located in parent view
View name: account.move.form.view.extend
请问怎么了?我该怎么做 ?谢谢。
解决方案
您对视图的定义不好。这就是它会被纠正的方式。
<record id="account_move_form_view_extend" model="ir.ui.view">
<field name="name">account.move.form.view.extend</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//header//button[@name='button_draft']" position="attributes">
<attribute name="groups">account.group_account_manager</attribute>
<attribute name="attrs">{'invisible' : [('show_reset_to_draft_button', '=', True)]}</attribute>
</xpath>
</field>
</record>
推荐阅读
- octave - Octave:如何为任意函数和任意数量的参数实现外积?
- java - 奇怪的语音流和通过 UDP 接收音频
- javascript - 预加载页面 javascript - 平滑淡出
- wordpress - 混合内容的 HTTPS 问题 - ARForms 插件
- java - 当editText聚焦并且键盘打开时如何移动视图?
- maven - IDEA 不再在运行前编译项目
- java - 指定顶级容器的 ContentPane 是否有优势?
- java - 如何在整个项目中传递一个值并在程序的任何地方使用它
- java - 通过 TestNG 在不同的浏览器上运行 selenium 测试
- java - Android Volley NoConnectionError