不能基于访问权限进行查看
cannot fiend view based on access rights
<record id="view_res_partner_pricelist" model="ir.ui.view">
<field name="name">view.res.partner.pricelist.form</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.view_partner_property_form" />
<field name="context">{'readonly_by_pass': True}</field>
<field name="arch" type="xml">
<xpath expr="//page[@name='accounting']" position="replace"/>
</field>
</record>
这是我隐藏“会计”选项卡的视图,如果打开联系表单的用户有会计和财务访问权限,它工作正常,但如果用户没有这些权限,我就会收到错误消息
AttributeError: Element '<xpath expr="//page[@name='accounting']">' cannot be located in parent view
Error context:
View `view.res.partner.pricelist.form`
如何让没有会计和财务访问权限的用户使用此功能?
有趣...您应该通过在视图的 groups_id 字段的视图记录定义中添加组要求来解决它,例如:
<record id="view_res_partner_pricelist" model="ir.ui.view">
<field name="name">view.res.partner.pricelist.form</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.view_partner_property_form" />
<field name="context">{'readonly_by_pass': True}</field>
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='accounting']" position="replace"/>
</field>
</record>
<record id="view_res_partner_pricelist" model="ir.ui.view">
<field name="name">view.res.partner.pricelist.form</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.view_partner_property_form" />
<field name="context">{'readonly_by_pass': True}</field>
<field name="arch" type="xml">
<xpath expr="//page[@name='accounting']" position="replace"/>
</field>
</record>
这是我隐藏“会计”选项卡的视图,如果打开联系表单的用户有会计和财务访问权限,它工作正常,但如果用户没有这些权限,我就会收到错误消息
AttributeError: Element '<xpath expr="//page[@name='accounting']">' cannot be located in parent view
Error context:
View `view.res.partner.pricelist.form`
如何让没有会计和财务访问权限的用户使用此功能?
有趣...您应该通过在视图的 groups_id 字段的视图记录定义中添加组要求来解决它,例如:
<record id="view_res_partner_pricelist" model="ir.ui.view">
<field name="name">view.res.partner.pricelist.form</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.view_partner_property_form" />
<field name="context">{'readonly_by_pass': True}</field>
<field name="groups_id" eval="[(4, ref('account.group_account_invoice'))]"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='accounting']" position="replace"/>
</field>
</record>