콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
2295 화면

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

the id for this view is view_sale_order_graph


아바타
취소
베스트 답변

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


아바타
취소
작성자

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

작성자

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

작성자

@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

작성자 베스트 답변

@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

아바타
취소

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.