Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
2240 Visualizzazioni

How can i hide an existing graph view for specific user groups?

the id for this view is view_sale_order_graph


Avatar
Abbandona
Risposta migliore

Hi,

You call python function on clicking the menu item and check the user groups from the python code and return the views from the python function accordingly.

Create Server action and Menu like this,

<record id="test_menu_action" model="ir.actions.server">
<field name="name">Test</field>
<field name="model_id" ref="model_test_test"/>
<field name="state">code</field>
<field name="code">action = model.test_test()</field>
</record>

<menuitem id="menu_external_id" name="Test" action="test_menu_action"/>
Then in the corresponding model,


class TestTest(models.Model):
_name = 'test.test'

def test_test(self):
# check user groups here
if 1 == 1: #give condition correctly
return {
'name': 'With Graph',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'graph,tree,form',
'domain': [],
'res_model': 'test.test',
'target': 'current'
}
else:
return {
'name': 'Without Graph',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'tree,form',
'domain': [],
'res_model': 'test.test',
'target': 'current'
}

Thanks


Avatar
Abbandona
Autore

i do not call the graph from any menu. i just click the already existing icon to switch from tree-view to graph-view.

graph view will be added there in the view_mode of the corresponding menu action

Autore

which menu? from a contact i click on "Sales" in the right upper buttons. then on right top location i already have the graph-icon.

i do not know which menuitem...

Autore

@Niyas Raphy: from a contact i click on "Sales" in the right upper buttons. then on right top location i already have the graph-icon. which (already existing) menu item do you mean?

It is called as smart button, there will be an action triggered on clicking it

Autore Risposta migliore

@Waleed Mohsen:

did the link help you? i don`t know if this will help because i already have existing graph view and icons in the list view that show the graph. i want to hide this icons

Avatar
Abbandona

I didn't try it. I tried to add a new security group and add users which I want to allow them to show the graph view but it doesn't as well.