cannot fiend view based on access rights

微笑、不失礼 提交于 2019-12-13 04:08:34

问题


<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>

this is my view where I hide tab Accounting, and it works ok if the user that opens contact form have accounting & finance access rights, but if the user doesn't have them then I get an error

AttributeError: Element '<xpath expr="//page[@name='accounting']">' cannot be located in parent view

Error context:
View `view.res.partner.pricelist.form`

how can I make this work for users who don't have accounting and finances access rights?


回答1:


Interesting... You should get it solved by adding the group requirement in the view record definition on the groups_id field of your view, like:

<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>


来源:https://stackoverflow.com/questions/52742613/cannot-fiend-view-based-on-access-rights

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!