[ADD] search by wubook / OTA code

Known Issue: Will fail if click in a checkin, invoices & folios. Known Issue: Will fail if reservation has more than one binding (not expected)
This commit is contained in:
Pablo
2019-02-27 19:48:42 +01:00
parent 0f0d2616d1
commit d39b22a257
2 changed files with 31 additions and 14 deletions

View File

@@ -230,19 +230,10 @@ var HotelCalendarView = AbstractRenderer.extend({
return domain;
},
_open_search_tree: function(type) {
var $elm = this.$el.find('#pms-menu #bookings_search');
var searchQuery = $elm.val();
var domain = false;
if (searchQuery) {
domain = this._generate_search_domain(searchQuery);
} else {
domain = [];
}
_generate_search_res_model: function(type) {
var model = '';
var title = '';
if (type === 'book' || type === 'book') {
if (type === 'book') {
model = 'hotel.reservation';
title = _t('Reservations');
} else if (type === 'checkin') {
@@ -255,6 +246,20 @@ var HotelCalendarView = AbstractRenderer.extend({
model = 'hotel.folio'
title = _t('Folios');
}
return [model, title];
},
_open_search_tree: function(type) {
var $elm = this.$el.find('#pms-menu #bookings_search');
var searchQuery = $elm.val();
var domain = false;
if (searchQuery) {
domain = this._generate_search_domain(searchQuery);
} else {
domain = [];
}
var [model, title] = this._generate_search_res_model(type);
this.do_action({
type: 'ir.actions.act_window',

View File

@@ -38,12 +38,24 @@ odoo.define('hotel_calendar_channel_connector.PMSHotelCalendarRenderer', functio
});
},
_generate_bookings_domain: function(tsearch) {
_generate_search_domain: function(tsearch) {
var domain = this._super(tsearch);
domain.splice(0, 0, '|');
domain.push(['external_id', 'ilike', tsearch]);
domain.push('|',
['channel_bind_ids.external_id', 'ilike', tsearch],
['channel_bind_ids.ota_reservation_id', 'ilike', tsearch]);
return domain;
}
},
_generate_search_res_model: function(type) {
var [model, title] = this._super(type);
if (type === 'book') {
model = 'hotel.reservation';
}
return [model, title];
},
});
return PMSHotelCalendarRenderer;