mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[REF] Change Hotel by PMS and Property concept
This commit is contained in:
BIN
pms/static/description/icon.png
Normal file
BIN
pms/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
28
pms/static/src/js/views/list/list_controller.js
Normal file
28
pms/static/src/js/views/list/list_controller.js
Normal file
@@ -0,0 +1,28 @@
|
||||
odoo.define('pms.ListController', function(require) {
|
||||
'use strict';
|
||||
/*
|
||||
* Pms
|
||||
* GNU Public License
|
||||
* Alexandre Díaz <dev@redneboa.es>
|
||||
*/
|
||||
|
||||
var ListController = require('web.ListController');
|
||||
var Core = require('web.core');
|
||||
|
||||
var _t = Core._t;
|
||||
|
||||
ListController.include({
|
||||
|
||||
renderButtons: function () {
|
||||
this._super.apply(this, arguments); // Sets this.$buttons
|
||||
var self = this;
|
||||
if (this.modelName === 'pms.reservation') {
|
||||
this.$buttons.append("<button class='btn btn-sm oe_open_reservation_wizard oe_highlight' type='button'>"+_t('Open Wizard')+"</button>");
|
||||
this.$buttons.find('.oe_open_reservation_wizard').on('click', function(){
|
||||
self.do_action('pms.open_wizard_reservations');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
61
pms/static/src/js/widgets/switch_hotel_menu.js
Normal file
61
pms/static/src/js/widgets/switch_hotel_menu.js
Normal file
@@ -0,0 +1,61 @@
|
||||
odoo.define('pms.SwitchPmsMenu', 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 SwitchPmsMenu = Widget.extend({
|
||||
template: 'pms.SwitchPmsMenu',
|
||||
willStart: function() {
|
||||
this.isMobile = config.device.isMobile;
|
||||
if (!session.user_pmss) {
|
||||
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 pms_property_id = $(ev.currentTarget).data('property-id');
|
||||
self._rpc({
|
||||
model: 'res.users',
|
||||
method: 'write',
|
||||
args: [[session.uid], {'pms_property_id': pms_property_id}],
|
||||
})
|
||||
.then(function() {
|
||||
location.reload();
|
||||
});
|
||||
}, 1500, true));
|
||||
|
||||
var properties_list = '';
|
||||
if (this.isMobile) {
|
||||
propertiess_list = '<li class="bg-info">' + _t('Tap on the list to change property') + '</li>';
|
||||
}
|
||||
else {
|
||||
self.$('.oe_topbar_name').text(session.user_properties.current_property[1]);
|
||||
}
|
||||
_.each(session.user_properties.allowed_propierties, function(property) {
|
||||
var a = '';
|
||||
if (property[0] === session.user_properties.current_property[0]) {
|
||||
a = '<i class="fa fa-check mr8"></i>';
|
||||
} else {
|
||||
a = '<span class="mr24"/>';
|
||||
}
|
||||
properties_list += '<li><a href="#" data-menu="property" data-property-id="' + property[0] + '">' + a + property[1] + '</a></li>';
|
||||
});
|
||||
self.$('.dropdown-menu').html(properties_list);
|
||||
return this._super();
|
||||
},
|
||||
});
|
||||
|
||||
SystrayMenu.Items.push(SwitchPmsMenu);
|
||||
|
||||
return SwitchPmsMenu;
|
||||
|
||||
});
|
||||
12
pms/static/src/xml/pms_base_templates.xml
Normal file
12
pms/static/src/xml/pms_base_templates.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
|
||||
<t t-name="pms.SwitchPmsMenu">
|
||||
<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>
|
||||
Reference in New Issue
Block a user