Hiding a page or group on the view

51 views
Skip to first unread message

Khurram Shahzad

unread,
Apr 4, 2017, 9:58:47 AM4/4/17
to try...@googlegroups.com
Dear All,

We want to hide a page in the notebook of a form for a specific user role. We want to keep it visible for all other roles. How can it be done? Similarly, a group in the form is also required to be set invisible for a specific user role. How can it be achieved?

--
 
Regards,
Khurram.

Sergi Almacellas Abellana

unread,
Apr 4, 2017, 10:05:40 AM4/4/17
to try...@googlegroups.com
El 04/04/17 a les 15:58, Khurram Shahzad ha escrit:
In the user context you have the groups which the user belongs to. Then
using the states attribute of the page/group (set using
view_attributes), you can hide the page/group if the user groups does
not contain the Id of your group.

Something like:

@classmethod
def view_attributes(cls):
return [('xpath/to/your/page', 'states', {
'invisible': ~In(Id(<module>, <id_group>), Eval('groups', []))})]

Where <module> is the module which created the group and <id_group> is
the xml_id of the group you want to test.

Another option is to set the name attribute of the group/page to a
related field and then restrict the access to this field. This is
usefull if the page only contains one field.

Hope it helps

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Khurram Shahzad

unread,
Apr 4, 2017, 10:18:16 AM4/4/17
to try...@googlegroups.com
Thank you so much for such a prompt response. Let me try it to be more thankful 😀.
Reply all
Reply to author
Forward
0 new messages