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 resets Notification User preference #293

Open
Marrieta99 opened this issue Jun 12, 2024 · 1 comment
Open

base_user_role resets Notification User preference #293

Marrieta99 opened this issue Jun 12, 2024 · 1 comment
Labels

Comments

@Marrieta99
Copy link

Module

base_user_role

Describe the bug

When a user's roles are altered,

To Reproduce

Affected versions: V17 at least, have not tried it in other versions

Steps to reproduce the behavior:

  1. A user changes their notification_type selection from 'Handle by Emails' (default) to 'Handle in Odoo'
  2. The user's roles list is modified (A role is added or removed)
  3. The user's notification_type has been set back to 'Handle by Emails'

Expected behavior
User's notification handling preferences shouldn't change, regardless of their roles

Additional context
Found this bug in my Odoo.sh instance. Version is 17.0+e (Enterprise Edition)
The bug was found in my productive (main) branch, and successfully replicated in a fresh dev database with only the base_user_role module installed

@Marrieta99 Marrieta99 added the bug label Jun 12, 2024
@COSTLAND
Copy link

Additional Information

I've been able to reproduce this bug in Odoo v16 Enterprise Edition as well. After further investigation, I've identified some additional details about the issue:

Root Cause

The issue appears to be linked with the recalculation of the User Types / Internal User group. When the last role containing the User Types / Internal User group is removed (even temporarily without saving), the user type is reset. This reset causes the user's notification type to revert to its default value (email).

Explanation

This behavior is consistent with normal Odoo operations regarding user types. When all roles containing the Internal User group are removed, even momentarily, Odoo recalculates the user type, which triggers a reset of user preferences, including the notification type.

Workaround

To prevent this reset from occurring, it's crucial to always maintain at least one role that contains the User Types / Internal User group for each user. Here's a step-by-step process to safely modify roles without triggering the reset:

  1. When replacing Role A with Role B (assuming both contain the Internal User group):
    a. First, add Role B to the user
    b. Save the changes
    c. Then, remove Role A

This approach ensures that the Internal User group is never completely removed during the process, avoiding the recalculation of the user type.

Alternative Solution

Create a separate user group dedicated to containing only the User Types / Internal User group. Always keep this group assigned to the user. This allows you to freely add, remove, or replace other roles without forcing a recalculation of the user type, thus avoiding the reset of user communication preferences.

SiesslPhillip pushed a commit to grueneerde/OCA-server-backend that referenced this issue Nov 20, 2024
Syncing from upstream OCA/server-backend (16.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