我想让模型"account.move"中的"Reset to Draft"按钮只对'account.group_account_invoice'可见,这意味着它对'ccount.ggroup_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>