mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Manage multihotel and multicompany
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
# Copyright 2019 Dario Lodeiros
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
from odoo import models, _
|
||||
from odoo.http import request
|
||||
from odoo.exceptions import MissingError
|
||||
|
||||
|
||||
class IrHttp(models.AbstractModel):
|
||||
@@ -13,8 +14,17 @@ class IrHttp(models.AbstractModel):
|
||||
res = super().session_info()
|
||||
user = request.env.user
|
||||
display_switch_hotel_menu = len(user.hotel_ids) > 1
|
||||
# TODO: limit hotels to the current company? or switch company automatically
|
||||
res['hotel_id'] = request.env.user.hotel_id.id if request.session.uid else None
|
||||
res['user_hotels'] = {'current_hotel': (user.hotel_id.id, user.hotel_id.name),
|
||||
'allowed_hotels': [(hotel.id, hotel.name) for hotel in
|
||||
user.hotel_ids]} if display_switch_hotel_menu else False
|
||||
if user.hotel_id.company_id in user.company_ids:
|
||||
user.company_id = user.hotel_id.company_id
|
||||
res['company_id'] = user.hotel_id.company_id.id
|
||||
else:
|
||||
raise MissingError(
|
||||
_("Wrong hotel and company access settings for this user. "
|
||||
"Please review hotel and company for user %s") % user.name)
|
||||
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user