El 04/04/17 a les 15:58, Khurram Shahzad ha escrit:
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?

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

--
You received this message because you are subscribed to the Google Groups 
"tryton" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton/2c811ab4-0e72-d052-eacd-52368e3d558a%40koolpi.com.

Reply via email to