Odoo- Hide field for multiple groups OR visible to multiple groups - odoo

e. The issue i am facing is that i need to show a field to multiple user groups. I know how to show field to one group
<field name="received_qty" groups="base.test_group" string="Total Received Quantity"/>
but i want to show this field to multiple groups (suppose :'base.group1','base.group2') and then it should be hidden from all other groups which are not listed here

Using , operator we can give groups name in field as many as we want.
For example:
groups="base.test_group,base.test_group1,base.test_group2"
It's combination of module_name.xml_group_id. Field can be visible for those User who has group checked.

Related

Odoo - Make a field invisible for 1 group

I want to make a control invisible for users of only 1 group. All users of other groups have the right to access this field.
I know how to do the opposite, that is to say, restrict access to the field to 1 group. But this way the list will be very long if I have to put all the groups. Is there a simple method, preferably with Odoo Studio?
Thanks in advance !
You can precede the group's external ID by !, for example:
groups="!website.group_multi_website"
The user_has_groups method (which is used to apply the groups) will return True if the current user is a member of one of the given groups not preceded by ! and is not member of any of the groups preceded by !

Searching for a user and associated groups on LDAP in one search

New to LDAP. The way our LDAP is arranged is People and groups. The people have user information such as name, uid, and mail. The groups have group name and multiple member field which has value like cn=First Last,cn=people,dc=comic,dc=com, listing the People that are members of the group.
Currently starting with userid and password, doing two searches:
1) Get user by searching on People base domain on uid=value. Then from the user get the first and last name.
2) Search on Groups base domain based on member=cn=First Last,cn=People,dc=comic,dc=com and iterate over the list of group objects returned to the group name field.
Am just wondering is there way to do all this in one search or are two searches necessary?
Unfortunately you cannot do what would like in one operation.
Also, what you are doing will not always work. Instead of retrieving the users first and last name you should retrieve their distinguished name (dn attribute) and do your group search based on that. First and last names can be modified within LDAP and can happen due to marriage / divorce / etc.
It is possible, provided that you implement a Reverse Group Membership Maintenance Overlay.
To determine which groups an entry is a member of without performing extra searches, the memberOf overlay is exactly what you need.
The memberof overlay updates an attribute (by default memberOf)
whenever changes occur to the membership attribute (by default member)
of entries of the objectclass (by default groupOfNames) configured to
trigger updates. Thus, it provides maintenance of the list of groups
an entry is a member of, when usual maintenance of groups is done by
modifying the members on the group entry.
You may find this Server Fault post useful for a how to.
Once you have memberOf attribute ready to be used, you may have to run ldapmodify manually on each group entries, but just once, so that all members entries can be provisioned with the corresponding group dn in their respective memberOf attribute.
Finally, to perform a group membership search for a given user, you would just search for the user entry and iterate the memberOf attribute to get group dn's.

Ldap Group filter query to excluse nested group in member list

I want to write the ldap group filter where I want to pull all the groups and their members but exclude nested group member within specified OU.
It will remove the chance of cyclic group.
For example Group A contains following member:
user 1
user 2
Group 1
In the query I only want Group A with user 1 and user 2.
The filter example is (&(objectClass=Group)(member=*)) but I do not know what are the options I can use in the member filter.
If you want to retrieve the members of a certain group you would use a filter like (&(objectClass=groupOfNames)(cn=rdn-of-the-very-group)) and include memberin the list of attributes to retrieve. Without further assistance by an extended search control you only will get direct members, so no worries about members of nested groups. In order to eliminate nested groups from the search result, include objectClassin the attribute list. You'll have to filter on the client side, though.

How can I create a filter to display all records created by group members in SharePoint 2010

I want to create a filter for list view, where I want to show all the records created by user group.
We all know [Me] will filter out the records which are craeted by me. i.e. Created by equals to = [Me]
How can I create a filter to display all records created by only the group members.
Please help, Thanks in advance.
I dont think you can do this out of the box.
A way to do this is to use an event receiver on that list, on item inserted / updated with some logic to extract the group from the user and populate a field of that item.
Once you have the column with the group value you can then apply a filter to it normally.
Reader here about event receivers:
https://www.nothingbutsharepoint.com/sites/devwiki/sp2007dev/pages/event%20receivers.aspx
You want to be looking at using event receivers on the SPListItem object.

Get models with distinct attribute ActiveRecord

I have a bunch of records in my database which all have the same Title but different Locations. Once I filter by within a location boundary, I want to filter out ones with the same Title. Is there an ActiveRecord way to do this? I know about select, but that will only return titles, and I actually need the entire record.
So I have a Business which has a Title. If I select all of the businesses within a given lat/long boundary, multiple instances with the same name (say, Subway) will be returned. I want to limit the result to 10.
In English: Given me ten records (the entire record, not just certain columns) where every title is unique amongst the ten returned.
You can simply use .first, i.e.
Venue.where(name: "Subway").first
If you need more than one element, pass a parameter to first:
Venue.where(name: "Subway").first(10)
To select one entry per distinct value in some column, you can use .group("column_name"):
Venue.where(some_condition).group("name")
ModelName.where(title: "Building")
If you provide a more specific question, I'll provide a more specific answer...