[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:
Kevin Khao
2020-03-04 18:33:24 +01:00
committed by Sébastien BEAU
parent efe0a694df
commit 0422b83c31
33 changed files with 1265 additions and 1 deletions

View 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