mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Multi Hotel initial import
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
Darío Lodeiros,\
|
||||
Jose Luis Algara,\
|
||||
Alexandre Díaz,\
|
||||
Q. Barriuso,',
|
||||
Pablo Quesada,',
|
||||
'category': 'Generic Modules/Hotel Management',
|
||||
'website': 'https://github.com/hootel/hootel',
|
||||
'depends': [
|
||||
@@ -22,6 +22,7 @@
|
||||
'license': "AGPL-3",
|
||||
'demo': ['data/hotel_demo.xml'],
|
||||
'data': [
|
||||
'data/hotel_data.xml',
|
||||
'security/hotel_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/massive_changes.xml',
|
||||
@@ -34,6 +35,9 @@
|
||||
'wizard/massive_price_reservation_days.xml',
|
||||
'wizard/folio_make_invoice_advance_views.xml',
|
||||
'data/hotel_sequence.xml',
|
||||
'views/inherited_res_company_views.xml',
|
||||
'views/inherited_res_users_views.xml',
|
||||
'views/hotel_property_views.xml',
|
||||
'views/hotel_floor_views.xml',
|
||||
'views/hotel_folio_views.xml',
|
||||
'views/inherited_res_partner_views.xml',
|
||||
@@ -56,6 +60,7 @@
|
||||
'views/hotel_checkin_partner_views.xml',
|
||||
'views/hotel_board_service_room_type_views.xml',
|
||||
'views/hotel_cancelation_rule_views.xml',
|
||||
'views/inherited_webclient_templates.xml',
|
||||
'data/cron_jobs.xml',
|
||||
'data/records.xml',
|
||||
'data/email_template_cancel.xml',
|
||||
@@ -65,5 +70,8 @@
|
||||
'report/hotel_folio_templates.xml',
|
||||
'report/hotel_folio.xml'
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/*.xml',
|
||||
],
|
||||
'installable': True
|
||||
}
|
||||
|
||||
16
hotel/data/hotel_data.xml
Normal file
16
hotel/data/hotel_data.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- keep noupdate to zero for development -->
|
||||
<data noupdate="1">
|
||||
<!-- Basic hotel -->
|
||||
<record id="main_hotel_property" model="hotel.property">
|
||||
<field name="name">My Hotel</field>
|
||||
|
||||
</record>
|
||||
|
||||
<record model="res.users" id="base.user_root">
|
||||
<field name="hotel_id" ref="main_hotel_property"/>
|
||||
<field name="hotel_ids" eval="[(4, ref('main_hotel_property'))]"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -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
|
||||
|
||||
17
hotel/models/hotel_property.py
Normal file
17
hotel/models/hotel_property.py
Normal 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')
|
||||
20
hotel/models/inherited_ir_http.py
Normal file
20
hotel/models/inherited_ir_http.py
Normal 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
|
||||
@@ -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 \
|
||||
|
||||
17
hotel/models/inherited_res_users.py
Normal file
17
hotel/models/inherited_res_users.py
Normal 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)
|
||||
61
hotel/static/src/js/widgets/switch_hotel_menu.js
Normal file
61
hotel/static/src/js/widgets/switch_hotel_menu.js
Normal file
@@ -0,0 +1,61 @@
|
||||
odoo.define('hotel.SwitchHotelMenu', function(require) {
|
||||
"use strict";
|
||||
|
||||
var config = require('web.config');
|
||||
var core = require('web.core');
|
||||
var session = require('web.session');
|
||||
var SystrayMenu = require('web.SystrayMenu');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
var SwitchHotelMenu = Widget.extend({
|
||||
template: 'hotel.SwitchHotelMenu',
|
||||
willStart: function() {
|
||||
this.isMobile = config.device.isMobile;
|
||||
if (!session.user_hotels) {
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
this.$el.on('click', '.dropdown-menu li a[data-menu]', _.debounce(function(ev) {
|
||||
ev.preventDefault();
|
||||
var hotel_id = $(ev.currentTarget).data('hotel-id');
|
||||
self._rpc({
|
||||
model: 'res.users',
|
||||
method: 'write',
|
||||
args: [[session.uid], {'hotel_id': hotel_id}],
|
||||
})
|
||||
.then(function() {
|
||||
location.reload();
|
||||
});
|
||||
}, 1500, true));
|
||||
|
||||
var hotels_list = '';
|
||||
if (this.isMobile) {
|
||||
hotels_list = '<li class="bg-info">' + _t('Tap on the list to change hotel') + '</li>';
|
||||
}
|
||||
else {
|
||||
self.$('.oe_topbar_name').text(session.user_hotels.current_hotel[1]);
|
||||
}
|
||||
_.each(session.user_hotels.allowed_hotels, function(hotel) {
|
||||
var a = '';
|
||||
if (hotel[0] === session.user_hotels.current_hotel[0]) {
|
||||
a = '<i class="fa fa-check mr8"></i>';
|
||||
} else {
|
||||
a = '<span class="mr24"/>';
|
||||
}
|
||||
hotels_list += '<li><a href="#" data-menu="hotel" data-hotel-id="' + hotel[0] + '">' + a + hotel[1] + '</a></li>';
|
||||
});
|
||||
self.$('.dropdown-menu').html(hotels_list);
|
||||
return this._super();
|
||||
},
|
||||
});
|
||||
|
||||
SystrayMenu.Items.push(SwitchHotelMenu);
|
||||
|
||||
return SwitchHotelMenu;
|
||||
|
||||
});
|
||||
12
hotel/static/src/xml/hotel_base_templates.xml
Normal file
12
hotel/static/src/xml/hotel_base_templates.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
|
||||
<t t-name="hotel.SwitchHotelMenu">
|
||||
<li class="o_switch_company_menu">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="#">
|
||||
<span t-attf-class="#{widget.isMobile ? 'fa fa-building-o' : 'oe_topbar_name'}"/> <span class="caret"/>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu"/>
|
||||
</li>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
50
hotel/views/hotel_property_views.xml
Normal file
50
hotel/views/hotel_property_views.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- views -->
|
||||
|
||||
<record id="hotel_property_views_form" model="ir.ui.view">
|
||||
<field name="name">hotel_property_views_form</field>
|
||||
<field name="model">hotel.property</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Hotel Configuration">
|
||||
<sheet>
|
||||
<label for="partner_id" class="oe_edit_only"/>
|
||||
<h1>
|
||||
<field name="partner_id" class="oe_inline" />
|
||||
</h1>
|
||||
<notebook>
|
||||
<page string="Hotel Settings" name="hotel_settings">
|
||||
<group colspan="4" col="4">
|
||||
<field name="company_id" class="oe_inline" />
|
||||
</group>
|
||||
<group colspan="4" col="4">
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_property_views_tree" model="ir.ui.view">
|
||||
<field name="name">hotel_property_views_tree</field>
|
||||
<field name="model">hotel.property</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Hotel settings summary">
|
||||
<field name="partner_id"/>
|
||||
<field name="company_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- actions -->
|
||||
|
||||
<record id="hotel_property_action" model="ir.actions.act_window">
|
||||
<field name="name">Hotel Property</field>
|
||||
<field name="res_model">hotel.property</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
20
hotel/views/inherited_res_company_views.xml
Normal file
20
hotel/views/inherited_res_company_views.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Hotel Settings -->
|
||||
<record id="res_company_view_form" model="ir.ui.view">
|
||||
<field name="name">view.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="base.view_company_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page" position="after">
|
||||
<page string="Hotels" name="hotel_page">
|
||||
<group name="hotel">
|
||||
<field name="hotel_ids"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
17
hotel/views/inherited_res_users_views.xml
Normal file
17
hotel/views/inherited_res_users_views.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="res_users_view_form" model="ir.ui.view">
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='access_rights']/group" position="after">
|
||||
<group string="Multi Hotels">
|
||||
<field string="Allowed Hotels" name="hotel_ids" widget="many2many_tags"/>
|
||||
<field string="Current Hotel" name="hotel_id" context="{'user_preference': 0}"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
10
hotel/views/inherited_webclient_templates.xml
Normal file
10
hotel/views/inherited_webclient_templates.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="assets_backend" name="hotel assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/hotel/static/src/js/widgets/switch_hotel_menu.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user