Skip to Content
Menu
This question has been flagged
1 Reply
2293 Views

 I'm trying to develop a small module to hide Graph view in purchase module and I tried the below way but not working with me. Any help on this will be appreciated.

What I did is below:

- created a group as below:

<record id="view_price" model="res.groups">
<field name="name">View All Prices</field>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>


   Then I tried to inherit the graph view and restrict access to the above group:

    

<record model="ir.ui.view" id="hide_purchase_order_graph">
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_graph"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_total']" position="attributes">
<attribute name="groups">hide_prices.view_price</attribute>
</xpath>
</field>
</record>

   

Avatar
Discard
Best Answer

Hi,


For this i will suggest you to use server action.  Upon clicking on the menu item you can call a  python function using server action.

Then inside the python function, you can check whether the user belongs to the corresponding group or not, based on the users group you can return the views.

Uptd :  To create a server action for a menu item have a look at this : https://www.odoo.com/forum/help-1/question/calling-a-python-method-directly-from-menuitem-63590

Thanks

Avatar
Discard
Author

Thanks Niyas for your reply. I never write a python code but I will give it a tray.

Author

Thank Niyas. I will have a look.