Hi sergi!
El 25/01/18 a las 11:57, Sergi Almacellas Abellana escribió:
> El 25/01/18 a les 15:24, Luciano Rossi ha escrit:
>> Hi!
>>
>> I need to create an interface to manage the users. For now, I add to my
>> module the menu item Administration -> Users.
>>
>> The problem that i'm having, is that I want to restrict the groups that
>> the user can add or remove from the groups field (many2many).
>>
>> I added a restriction to the groups field, modifying the definition of
>> the domain attribute of the groups field, so when choosing the groups to
>> be added, it will restrict the list of them. But, I don't know how I can
>> restrict the lines (groups) that the user can remove.
>
> The user will be allowed to add and remove all the groups that are
> allowed by domain.
>
>>
>> For example, the user can add to the user the groups Accounts and
>> Purchase. But, if the user already has the group Sale, I do not want
>> that this group to be remove it.
>>
>> Any idea?
>
> If the idea is to prevent removal of existing groups I will probably
> make the current user groups readonly and add a function field which is
> empty by default and it's used to add new groups to the user.
>
It's a good idea. Perhaps the function field should not be empty. May
be, it could retrieve only the groups that the user has, but that are
allowed to add or remove it.
> But for sure, this should be done with access groups, so there are
> groups that are allowed to write directly and remove groups.
>
If I understand, yes, this new "group" could not modify or remove the
groups, just add or remove it from the groups field at User model.
> Hope it helps.