Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base_user_role - user deletion from form views #306

Open
ad-peleng opened this issue Sep 3, 2024 · 2 comments
Open

base_user_role - user deletion from form views #306

ad-peleng opened this issue Sep 3, 2024 · 2 comments
Labels

Comments

@ad-peleng
Copy link

ad-peleng commented Sep 3, 2024

Module

base_user_role

Describe the bug

  1. From the role form view, on the users tab, each user entry has a trash can icon. Clicking this icon does not remove the user from the role. Instead, it deletes the user.
  2. From the user form view, on the roles tab, each role entry has a trash can icon. Clicking this icon does not remove teh user from the role. Instead, it deletes the user.

To Reproduce

Affected versions:
Odoo 16

Steps to reproduce the behavior:

  1. Settings > Users & Companies > Roles
  2. Select a role from the list
  3. "Users" tab
  4. Click trash can icon on a user entry line
  5. The user is now "deleted": Does not appear in users list and cannot login.

Alternatively,

  1. Settings > Users & Companies > Users
  2. Select a user from the list
  3. "Roles" tab
  4. Click trash can icon on a role entry line
  5. The user is now "deleted": Does not appear in users list and cannot login.

Expected behavior
The user list on the role form view should have "x" icons that remove the user from the role, but do not delete the user. The trash can icon should not be available.
The role list on the user form view should have "x" icons that remove the role from the user, but do not delete the user. The trash can icon should not be available.
I believe this should behave like the "Groups" tab on the roles form view:

  1. Settings > Users & Companies > Roles
  2. Select a role from the list
  3. "Groups" tab
  4. Click the "x" icon on a group entry line.
  5. The group is now removed from the role, but is not deleted.

Additional context
Windows Server 2022, Odoo 16 Community, Python 3.10.11

@ad-peleng ad-peleng added the bug label Sep 3, 2024
@COSTLAND
Copy link

COSTLAND commented Sep 5, 2024

I believe I can provide some clarification on what's happening here.

Root Cause

The behavior you're experiencing is not actually deleting the user, but rather making the user invisible in the Users menu due to how Odoo's record rules work. Here's what's happening:

  1. The default domain for viewing users in the Settings > Users & Companies > Users menu is:
    ['|', ('share', '=', False), ('company_ids', 'in', company_ids)]
    

image

This means users are only visible if they are either internal users or belong to one of the current user's companies.

  1. When you remove a role from a user (or a user from a role), if that role was the only one assigning the user to internal groups (or any user types group), the user effectively lost user types.

  2. As a result, the user no longer matches the default domain for the Users menu and disappears from view. However, the user still exists in the system and can be found in Contacts.

How to Resolve

If you need to "recover" a user that has disappeared:

  1. Temporarily disable the user record rule. This will allow you to see all users, including those without internal groups.
    image

  2. Find the affected user and assign them to a role or group that belongs to the internal user types.

  3. Re-enable the user record rule.

The user should now be visible again in the Users menu.

@ad-peleng
Copy link
Author

Thank you for this feedback. I still believe that this is a bug because I believe that the behavior is unintended by the designer and unanticipated by the user. Nonetheless, after reading your feedback, I see that it does not present as intractable a situation as I first thought.

My solution will be to create a role for all internal users which only applies the group "User Types / Internal User". All other roles will be applied in addition to this role. Since this role will never be removed, I should not encounter the undesired behavior and I will be able to add and remove all other roles to users without consequence. This solution has worked in testing.

I am posting my solution for the benefit of other users. This solution is sufficient for my needs, but I encourage the OCA team to consider addressing this issue for the next release. Thanks again.

SiesslPhillip pushed a commit to grueneerde/OCA-server-backend that referenced this issue Nov 20, 2024
Syncing from upstream OCA/server-backend (17.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants