mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[ADD][12.0] base_user_role_profile: Add to 12.0
fixup! Logic and permissions fixes, new demo module, changes JS-side that reloads in a cleaner way on profile change fixup! removed unused imports, beautified JS fixup! Test coverage increase [FIX] Use write instead of assignment operator on create function: assignment on multiple records raises error fixup! Removed leftover copyright Apply suggestions from code review Co-Authored-By: David Beal <david.beal@akretion.com>
This commit is contained in:
26
base_user_role_profile/models/ir_http.py
Normal file
26
base_user_role_profile/models/ir_http.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class Http(models.AbstractModel):
|
||||
_inherit = "ir.http"
|
||||
|
||||
def session_info(self): # pragma: no cover
|
||||
result = super().session_info()
|
||||
user = request.env.user
|
||||
allowed_profiles = [
|
||||
(profile.id, profile.name) for profile in user.profile_ids
|
||||
]
|
||||
if len(allowed_profiles) > 1:
|
||||
current_profile = (user.profile_id.id, user.profile_id.name)
|
||||
result["user_profiles"] = {
|
||||
"current_profile": current_profile,
|
||||
"allowed_profiles": allowed_profiles,
|
||||
}
|
||||
else:
|
||||
result["user_profiles"] = False
|
||||
result["profile_id"] = (
|
||||
user.profile_id.id if request.session.uid else None
|
||||
)
|
||||
return result
|
||||
Reference in New Issue
Block a user