Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
3580 Tampilan

As in subject.

How can I hide menu depending on what is user department_id ?

Already tried use domain:

ex:

domain="[('department_id', '=', Warehouse)]"
filter_domain="[('department_id', '=', Warehouse)]"

but ....

File "lxml.etree.pyx", line 3027, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:129517)
AssertionError: Invalid attribute filter_domain for element menuitem, line 226


no luck.

Avatar
Buang

This is totally wrong question. Please double check your question. You can never hide menu depending on data. I think you want to know, how to hide data based on department_id ?

Penulis

Question is actually correct. How can i hide menu depending on department_id. So if user working on Warehouse is logged in selected menu should appear or disappear. In this case Menu for Warehouse should be displayed. How can I do it then ?

Jawaban Terbai

via groups.

Actually, menu definition is as follows

 <menuitem id="menu_act_for_warehouse" action="act_for_warehouse" sequence="2" parent="some_parent_id"/> 

Where 'act_for_warehouse' is the action id that call a specific view.

You have to define a group for all users in department A, say. You have after that to rewrite the menu definition as follows

<menuitem id="menu_act_for_warehouse" action="act_for_warehouse" sequence="2" parent="some_parent_id" groups="your_module_name.group_for_department_a"/>

This menu will be seen only by the users in the group 'group_for_department_a', and other users won't see it. This is the most trivia solution even it requires double work. I mean, you have to add users to department and add them also to the group that is related to this department.

I think one can invent other solution that avoid double work. Try this first and let us see.
 




Avatar
Buang
Penulis

OK, done, created groups, assigned users to the groups and it works beautifully :)