[ADD] Multi Hotel initial import

This commit is contained in:
Pablo
2019-07-17 12:32:29 +02:00
committed by Dario Lodeiros
parent f18b73b344
commit 676e1b253f
13 changed files with 254 additions and 1 deletions

View File

@@ -2,8 +2,11 @@
# Copyright 2018 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import inherited_ir_http
from . import inherited_payment_return
from . import hotel_board_service_room_type
from . import hotel_property
from . import inherited_res_users
from . import hotel_floor
from . import hotel_folio
from . import hotel_reservation

View File

@@ -0,0 +1,17 @@
# Copyright 2019 Pablo Quesada
# Copyright 2019 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api, fields
class HotelProperty(models.Model):
_name = 'hotel.property'
_description = 'Hotel'
_inherits = {'res.partner': 'partner_id'}
partner_id = fields.Many2one('res.partner', 'Hotel Property',
required=True, delegate=True, ondelete='cascade')
company_id = fields.Many2one('res.company', help='The company that owns or operates this hotel.')
user_ids = fields.Many2many('res.users', 'hotel_property_users_rel', 'hotel_id', 'user_id',
string='Accepted Users')

View File

@@ -0,0 +1,20 @@
# Copyright 2019 Pablo Quesada
# Copyright 2019 Dario Lodeiros
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from odoo.http import request
class IrHttp(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
res = super().session_info()
user = request.env.user
display_switch_hotel_menu = len(user.hotel_ids) > 1
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
return res

View File

@@ -7,6 +7,8 @@ from odoo import models, fields
class ResCompany(models.Model):
_inherit = 'res.company'
hotel_ids = fields.One2many('hotel.property', 'company_id', 'Hotels')
additional_hours = fields.Integer('Additional Hours',
help="Provide the min hours value for \
check in, checkout days, whatever \

View File

@@ -0,0 +1,17 @@
# Copyright 2019 Pablo Quesada
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api, fields
class ResUsers(models.Model):
_inherit = 'res.users'
@api.model
def _get_default_hotel(self):
return self.env.user.hotel_id
hotel_id = fields.Many2one('hotel.property', string='Hotel', default=_get_default_hotel,
help='The hotel this user is currently working for.',
context={'user_preference': True})
hotel_ids = fields.Many2many('hotel.property', 'hotel_property_users_rel', 'user_id', 'hotel_id',
string='Hotels', default=_get_default_hotel)