mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP][MIG][11.0] hotel_connector
This commit is contained in:
@@ -7,9 +7,9 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
_inherit = 'hotel.calendar.management'
|
||||
|
||||
@api.model
|
||||
def _get_availability_values(self, avail, vroom):
|
||||
def _get_availability_values(self, avail, room_type):
|
||||
vals = super(HotelCalendarManagement, self)._get_availability_values(
|
||||
avail, vroom)
|
||||
avail, room_type)
|
||||
vals.update({'wmax_avail': vals['avail']})
|
||||
return vals
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
'summary': "Hotel Channel Connector Base",
|
||||
'description': "Hotel Channel Connector Base",
|
||||
'depends': [
|
||||
'hotel',
|
||||
'connector',
|
||||
'hotel',
|
||||
],
|
||||
'external_dependencies': {
|
||||
'python': ['xmlrpc']
|
||||
|
||||
@@ -8,7 +8,7 @@ class HotelConnectorModelBinder(Component):
|
||||
_inherit = ['base.binder', 'base.hotel.channel.connector']
|
||||
_apply_on = [
|
||||
'channel.hotel.reservation',
|
||||
'channel.hotel.virtual.room',
|
||||
'channel.hotel.room.type',
|
||||
'channel.hotel.room.type.availability',
|
||||
'channel.hotel.room.type.restriction',
|
||||
'channel.product.pricelist',
|
||||
|
||||
@@ -23,34 +23,34 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def push_availability(self):
|
||||
vroom_avail_ids = self.env['hotel.room.type.availability'].search([
|
||||
room_type_avail_ids = self.env['hotel.room.type.availability'].search([
|
||||
('wpushed', '=', False),
|
||||
('date', '>=', date_utils.now(hours=False).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT))
|
||||
])
|
||||
|
||||
vrooms = vroom_avail_ids.mapped('room_type_id')
|
||||
room_types = room_type_avail_ids.mapped('room_type_id')
|
||||
avails = []
|
||||
for vroom in vrooms:
|
||||
vroom_avails = vroom_avail_ids.filtered(
|
||||
lambda x: x.room_type_id.id == vroom.id)
|
||||
for room_type in room_types:
|
||||
room_type_avails = room_type_avail_ids.filtered(
|
||||
lambda x: x.room_type_id.id == room_type.id)
|
||||
days = []
|
||||
for vroom_avail in vroom_avails:
|
||||
vroom_avail.with_context({
|
||||
for room_type_avail in room_type_avails:
|
||||
room_type_avail.with_context({
|
||||
'wubook_action': False}).write({'wpushed': True})
|
||||
wavail = vroom_avail.avail
|
||||
if wavail > vroom_avail.wmax_avail:
|
||||
wavail = vroom_avail.wmax_avail
|
||||
wavail = room_type_avail.avail
|
||||
if wavail > room_type_avail.wmax_avail:
|
||||
wavail = room_type_avail.wmax_avail
|
||||
date_dt = date_utils.get_datetime(
|
||||
vroom_avail.date,
|
||||
room_type_avail.date,
|
||||
dtformat=DEFAULT_SERVER_DATE_FORMAT)
|
||||
days.append({
|
||||
'date': date_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
'avail': wavail,
|
||||
'no_ota': vroom_avail.no_ota and 1 or 0,
|
||||
# 'booked': vroom_avail.booked and 1 or 0,
|
||||
'no_ota': room_type_avail.no_ota and 1 or 0,
|
||||
# 'booked': room_type_avail.booked and 1 or 0,
|
||||
})
|
||||
avails.append({'id': vroom.wrid, 'days': days})
|
||||
avails.append({'id': room_type.wrid, 'days': days})
|
||||
_logger.info("UPDATING AVAILABILITY IN WUBOOK...")
|
||||
_logger.info(avails)
|
||||
if any(avails):
|
||||
@@ -84,19 +84,19 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
[('wpushed', '=', False), ('pricelist_id', '=', pr.id)])
|
||||
product_tmpl_ids = unpushed_pl.mapped('product_tmpl_id')
|
||||
for pt_id in product_tmpl_ids:
|
||||
vroom = self.env['hotel.room.type'].search([
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', pt_id.id)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
prices[pr.wpid].update({vroom.wrid: []})
|
||||
if room_type:
|
||||
prices[pr.wpid].update({room_type.wrid: []})
|
||||
for i in range(0, days_diff):
|
||||
prod = vroom.product_id.with_context({
|
||||
prod = room_type.product_id.with_context({
|
||||
'quantity': 1,
|
||||
'pricelist': pr.id,
|
||||
'date': (date_start + timedelta(days=i)).
|
||||
strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
})
|
||||
prices[pr.wpid][vroom.wrid].append(prod.price)
|
||||
prices[pr.wpid][room_type.wrid].append(prod.price)
|
||||
_logger.info("UPDATING PRICES IN WUBOOK...")
|
||||
_logger.info(prices)
|
||||
for k_pk, v_pk in prices.iteritems():
|
||||
@@ -110,7 +110,7 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def push_restrictions(self):
|
||||
vroom_rest_obj = self.env['hotel.room.type.restriction']
|
||||
room_type_rest_obj = self.env['hotel.room.type.restriction']
|
||||
rest_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
unpushed = rest_item_obj.search([
|
||||
('wpushed', '=', False),
|
||||
@@ -129,7 +129,7 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
date_end,
|
||||
hours=False) + 1
|
||||
restrictions = {}
|
||||
restriction_plan_ids = vroom_rest_obj.search([
|
||||
restriction_plan_ids = room_type_rest_obj.search([
|
||||
('wpid', '!=', False),
|
||||
('active', '=', True)
|
||||
])
|
||||
@@ -140,14 +140,14 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
('restriction_id', '=', rp.id)
|
||||
])
|
||||
room_type_ids = unpushed_rp.mapped('room_type_id')
|
||||
for vroom in room_type_ids:
|
||||
restrictions[rp.wpid].update({vroom.wrid: []})
|
||||
for room_type in room_type_ids:
|
||||
restrictions[rp.wpid].update({room_type.wrid: []})
|
||||
for i in range(0, days_diff):
|
||||
ndate_dt = date_start + timedelta(days=i)
|
||||
restr = vroom.get_restrictions(
|
||||
restr = room_type.get_restrictions(
|
||||
ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
if restr:
|
||||
restrictions[rp.wpid][vroom.wrid].append({
|
||||
restrictions[rp.wpid][room_type.wrid].append({
|
||||
'min_stay': restr.min_stay or 0,
|
||||
'min_stay_arrival': restr.min_stay_arrival or 0,
|
||||
'max_stay': restr.max_stay or 0,
|
||||
@@ -157,7 +157,7 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
'closed_departure': restr.closed_departure and 1 or 0,
|
||||
})
|
||||
else:
|
||||
restrictions[rp.wpid][vroom.wrid].append({})
|
||||
restrictions[rp.wpid][room_type.wrid].append({})
|
||||
_logger.info("UPDATING RESTRICTIONS IN WUBOOK...")
|
||||
_logger.info(restrictions)
|
||||
for k_res, v_res in restrictions.iteritems():
|
||||
|
||||
@@ -16,10 +16,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
_usage = 'channel.importer'
|
||||
|
||||
@api.model
|
||||
def _get_room_values_availability(self, vroom_id, date_str, day_vals, set_max_avail):
|
||||
def _get_room_values_availability(self, room_type_id, date_str, day_vals, set_max_avail):
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
vroom_avail = room_type_avail_obj.search([
|
||||
('room_type_id', '=', vroom_id),
|
||||
room_type_avail = room_type_avail_obj.search([
|
||||
('room_type_id', '=', room_type_id),
|
||||
('date', '=', date_str)
|
||||
], limit=1)
|
||||
vals = {
|
||||
@@ -30,13 +30,13 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
}
|
||||
if set_wmax_avail:
|
||||
vals.update({'wmax_avail': day_vals.get('avail', 0)})
|
||||
if vroom_avail:
|
||||
vroom_avail.with_context({
|
||||
if room_type_avail:
|
||||
room_type_avail.with_context({
|
||||
'wubook_action': False,
|
||||
}).write(vals)
|
||||
else:
|
||||
vals.update({
|
||||
'room_type_id': vroom_id,
|
||||
'room_type_id': room_type_id,
|
||||
'date': date_str,
|
||||
})
|
||||
room_type_avail_obj.with_context({
|
||||
@@ -45,10 +45,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
}).create(vals)
|
||||
|
||||
@api.model
|
||||
def _get_room_values_restrictions(self, restriction_plan_id, vroom_id, date_str, day_vals):
|
||||
vroom_restr_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
vroom_restr = vroom_restr_item_obj.search([
|
||||
('room_type_id', '=', vroom_id),
|
||||
def _get_room_values_restrictions(self, restriction_plan_id, room_type_id, date_str, day_vals):
|
||||
room_type_restr_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
room_type_restr = room_type_restr_item_obj.search([
|
||||
('room_type_id', '=', room_type_id),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('date_start', '=', date_str),
|
||||
('date_end', '=', date_str),
|
||||
@@ -72,19 +72,19 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
False)),
|
||||
'wpushed': True,
|
||||
}
|
||||
if vroom_restr:
|
||||
vroom_restr.with_context({
|
||||
if room_type_restr:
|
||||
room_type_restr.with_context({
|
||||
'wubook_action': False,
|
||||
}).write(vals)
|
||||
else:
|
||||
vals.update({
|
||||
'restriction_id': restriction_plan_id,
|
||||
'room_type_id': vroom_id,
|
||||
'room_type_id': room_type_id,
|
||||
'date_start': date_str,
|
||||
'date_end': date_str,
|
||||
'applied_on': '0_room_type',
|
||||
})
|
||||
vroom_restr_item_obj.with_context({
|
||||
room_type_restr_item_obj.with_context({
|
||||
'wubook_action': False,
|
||||
}).create(vals)
|
||||
|
||||
@@ -96,24 +96,24 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
_logger.info("==== ROOM VALUES (%s -- %s)", dfrom, dto)
|
||||
_logger.info(values)
|
||||
for k_rid, v_rid in values.iteritems():
|
||||
vroom = hotel_room_type_obj.search([
|
||||
room_type = hotel_room_type_obj.search([
|
||||
('wrid', '=', k_rid)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
if room_type:
|
||||
date_dt = date_utils.get_datetime(
|
||||
dfrom,
|
||||
dtformat=DEFAULT_WUBOOK_DATE_FORMAT)
|
||||
for day_vals in v_rid:
|
||||
date_str = date_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
self._get_room_values_availability(
|
||||
vroom.id,
|
||||
room_type.id,
|
||||
date_str,
|
||||
day_vals,
|
||||
set_max_avail)
|
||||
if def_restr_plan:
|
||||
self._get_room_values_restrictions(
|
||||
def_restr_plan.id,
|
||||
vroom.id,
|
||||
room_type.id,
|
||||
date_str,
|
||||
day_vals)
|
||||
date_dt = date_dt + timedelta(days=1)
|
||||
@@ -122,7 +122,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
@api.model
|
||||
def _generate_booking_vals(self, broom, checkin_str, checkout_str,
|
||||
is_cancellation, wchannel_info, wstatus, crcode,
|
||||
rcode, vroom, split_booking, dates_checkin,
|
||||
rcode, room_type, split_booking, dates_checkin,
|
||||
dates_checkout, book):
|
||||
# Generate Reservation Day Lines
|
||||
reservation_line_ids = []
|
||||
@@ -142,7 +142,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
'price': brday['price']
|
||||
}))
|
||||
tprice += brday['price']
|
||||
persons = vroom.wcapacity
|
||||
persons = room_type.wcapacity
|
||||
if 'ancillary' in broom and 'guests' in broom['ancillary']:
|
||||
persons = broom['ancillary']['guests']
|
||||
vals = {
|
||||
@@ -159,7 +159,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
'wstatus': wstatus,
|
||||
'to_read': True,
|
||||
'state': is_cancellation and 'cancelled' or 'draft',
|
||||
'room_type_id': vroom.id,
|
||||
'room_type_id': room_type.id,
|
||||
'splitted': split_booking,
|
||||
'wbook_json': json.dumps(book),
|
||||
'wmodified': book['was_modified']
|
||||
@@ -203,7 +203,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
res_partner_obj = self.env['res.partner']
|
||||
hotel_reserv_obj = self.env['hotel.reservation']
|
||||
hotel_folio_obj = self.env['hotel.folio']
|
||||
hotel_vroom_obj = self.env['hotel.room.type']
|
||||
hotel_room_type_obj = self.env['hotel.room.type']
|
||||
# Space for store some data for construct folios
|
||||
processed_rids = []
|
||||
failed_reservations = []
|
||||
@@ -319,13 +319,13 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
used_rooms = []
|
||||
# Iterate booked rooms
|
||||
for broom in book['booked_rooms']:
|
||||
vroom = hotel_vroom_obj.search([
|
||||
room_type = hotel_room_type_obj.search([
|
||||
('wrid', '=', broom['room_id'])
|
||||
], limit=1)
|
||||
if not vroom:
|
||||
if not room_type:
|
||||
self.create_channel_connector_issue(
|
||||
'reservation',
|
||||
"Can't found any virtual room associated to '%s' \
|
||||
"Can't found any room type associated to '%s' \
|
||||
in this hotel" % book['rooms'],
|
||||
'', wid=book['reservation_code'])
|
||||
failed_reservations.append(crcode)
|
||||
@@ -350,7 +350,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
bstatus,
|
||||
crcode,
|
||||
rcode,
|
||||
vroom,
|
||||
room_type,
|
||||
split_booking,
|
||||
dates_checkin,
|
||||
dates_checkout,
|
||||
@@ -362,10 +362,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
"Invalid reservation total price! %.2f != %.2f" % (vals['price_unit'], book['amount']),
|
||||
'', wid=book['reservation_code'])
|
||||
|
||||
free_rooms = hotel_vroom_obj.check_availability_room(
|
||||
free_rooms = hotel_room_type_obj.check_availability_room(
|
||||
checkin_str,
|
||||
checkout_str,
|
||||
room_type_id=vroom.id,
|
||||
room_type_id=room_type.id,
|
||||
notthis=used_rooms)
|
||||
if any(free_rooms):
|
||||
vals.update({
|
||||
@@ -407,7 +407,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
bstatus,
|
||||
crcode,
|
||||
rcode,
|
||||
vroom,
|
||||
room_type,
|
||||
False,
|
||||
(checkin_utc_dt, False),
|
||||
(checkout_utc_dt, False),
|
||||
@@ -415,8 +415,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
)
|
||||
vals.update({
|
||||
'product_id':
|
||||
vroom.room_ids[0].product_id.id,
|
||||
'name': vroom.name,
|
||||
room_type.room_ids[0].product_id.id,
|
||||
'name': room_type.name,
|
||||
'overbooking': True,
|
||||
})
|
||||
reservations.append((0, False, vals))
|
||||
@@ -497,7 +497,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
|
||||
vals = {
|
||||
'name': plan['name'],
|
||||
'wdaily': plan['daily'] == 1,
|
||||
'is_daily_plan': plan['daily'] == 1,
|
||||
}
|
||||
plan_id = product_listprice_obj.search([
|
||||
('wpid', '=', str(plan['id']))
|
||||
@@ -527,10 +527,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
for i in range(0, days_diff):
|
||||
ndate_dt = dfrom_dt + timedelta(days=i)
|
||||
for k_rid, v_rid in plan_prices.iteritems():
|
||||
vroom = hotel_room_type_obj.search([
|
||||
room_type = hotel_room_type_obj.search([
|
||||
('wrid', '=', k_rid)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
if room_type:
|
||||
pricelist_item = pricelist_item_obj.search([
|
||||
('pricelist_id', '=', pricelist.id),
|
||||
('date_start', '=', ndate_dt.strftime(
|
||||
@@ -539,7 +539,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('compute_price', '=', 'fixed'),
|
||||
('applied_on', '=', '1_product'),
|
||||
('product_tmpl_id', '=', vroom.product_id.product_tmpl_id.id)
|
||||
('product_tmpl_id', '=', room_type.product_id.product_tmpl_id.id)
|
||||
], limit=1)
|
||||
vals = {
|
||||
'fixed_price': plan_prices[k_rid][i],
|
||||
@@ -557,7 +557,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
DEFAULT_SERVER_DATE_FORMAT),
|
||||
'compute_price': 'fixed',
|
||||
'applied_on': '1_product',
|
||||
'product_tmpl_id': vroom.product_id.product_tmpl_id.id
|
||||
'product_tmpl_id': room_type.product_id.product_tmpl_id.id
|
||||
})
|
||||
pricelist_item_obj.with_context({
|
||||
'wubook_action': False}).create(vals)
|
||||
@@ -600,10 +600,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
], limit=1)
|
||||
if restriction_id:
|
||||
for k_rid, v_rid in v_rpid.iteritems():
|
||||
vroom = hotel_room_type_obj.search([
|
||||
room_type = hotel_room_type_obj.search([
|
||||
('wrid', '=', k_rid)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
if room_type:
|
||||
for item in v_rid:
|
||||
date_dt = date_utils.get_datetime(
|
||||
item['date'],
|
||||
@@ -615,7 +615,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
('date_end', '=', date_dt.strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('room_type_id', '=', vroom.id)
|
||||
('room_type_id', '=', room_type.id)
|
||||
], limit=1)
|
||||
vals = {
|
||||
'closed_arrival': item['closed_arrival'],
|
||||
@@ -638,7 +638,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
'date_end': date_dt.strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT),
|
||||
'applied_on': '0_room_type',
|
||||
'room_type_id': vroom.id
|
||||
'room_type_id': room_type.id
|
||||
})
|
||||
restriction_item_obj.with_context({
|
||||
'wubook_action': False}).create(vals)
|
||||
@@ -673,7 +673,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
try:
|
||||
results = self.backend_adapter.fetch_rooms()
|
||||
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
count = len(results)
|
||||
for room in results:
|
||||
vals = {
|
||||
@@ -684,11 +684,11 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
'wcapacity': room['occupancy'],
|
||||
# 'max_real_rooms': room['availability'],
|
||||
}
|
||||
vroom = vroom_obj.search([('wrid', '=', room['id'])], limit=1)
|
||||
if vroom:
|
||||
vroom.with_context({'wubook_action': False}).write(vals)
|
||||
room_type = room_type_obj.search([('wrid', '=', room['id'])], limit=1)
|
||||
if room_type:
|
||||
room_type.with_context({'wubook_action': False}).write(vals)
|
||||
else:
|
||||
vroom_obj.with_context({'wubook_action': False}).create(vals)
|
||||
room_type_obj.with_context({'wubook_action': False}).create(vals)
|
||||
except ValidationError:
|
||||
self.create_issue('room', _("Can't import rooms from WuBook"), results)
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ class website_wubook(http.Controller):
|
||||
parity_restr_id = request.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id')
|
||||
if parity_restr_id:
|
||||
vroom_restr_obj = request.env['hotel.room.type.restriction']
|
||||
restr_id = vroom_restr_obj.sudo().browse(int(parity_restr_id))
|
||||
room_type_restr_obj = request.env['hotel.room.type.restriction']
|
||||
restr_id = room_type_restr_obj.sudo().browse(int(parity_restr_id))
|
||||
if restr_id and restr_id.wpid and restr_id.wpid != '0':
|
||||
wubook_obj.fetch_rplan_restrictions(dfrom, dto,
|
||||
rpid=restr_id.wpid)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
from odoo.addons.queue_job.job import job, related_action
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
@@ -45,10 +46,14 @@ class ChannelHotelReservation(models.Model):
|
||||
default='0',
|
||||
readonly=True)
|
||||
wstatus_reason = fields.Char("WuBook Status Reason", readonly=True)
|
||||
customer_notes = fields.Text(related='folio_id.customer_notes',
|
||||
old_name='wcustomer_notes')
|
||||
wmodified = fields.Boolean("WuBook Modified", readonly=True, default=False)
|
||||
|
||||
@api.depends('channel_reservation_id', 'ota_id')
|
||||
def _is_from_ota(self):
|
||||
for record in self:
|
||||
record.odoo_id.is_from_ota = (record.channel_reservation_id and \
|
||||
record.ota_id)
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@related_action(action='related_action_unwrap_binding')
|
||||
@api.multi
|
||||
@@ -77,26 +82,21 @@ class ChannelHotelReservation(models.Model):
|
||||
class HotelReservation(models.Model):
|
||||
_inherit = 'hotel.reservation'
|
||||
|
||||
@api.depends('channel_bind_ids.channel_reservation_id', 'channel_bind_ids.ota_id')
|
||||
def _is_from_ota(self):
|
||||
for record in self:
|
||||
record.is_from_ota = (record.channel_bind_ids.channel_reservation_id and \
|
||||
record.channel_bind_ids.ota_id)
|
||||
|
||||
@api.multi
|
||||
def _set_access_for_wubook_fields(self):
|
||||
for rec in self:
|
||||
for record in self:
|
||||
user = self.env['res.users'].browse(self.env.uid)
|
||||
rec.able_to_modify_channel = user.has_group('base.group_system')
|
||||
record.able_to_modify_channel = user.has_group('base.group_system')
|
||||
|
||||
is_from_ota = fields.Boolean('Is From OTA',
|
||||
compute=_is_from_ota, store=False,
|
||||
readonly=True,
|
||||
old_name='wis_from_channel')
|
||||
able_to_modify_channel = fields.Boolean(compute=_set_access_for_wubook_fields,
|
||||
string='Is user able to modify wubook fields?',
|
||||
old_name='able_to_modify_wubook')
|
||||
to_read = fields.Boolean('To Read', default=False)
|
||||
customer_notes = fields.Text(related='folio_id.customer_notes',
|
||||
old_name='wcustomer_notes')
|
||||
|
||||
@api.depends('channel_type', 'ota_id')
|
||||
def _get_origin_sale(self):
|
||||
@@ -133,7 +133,6 @@ class HotelReservation(models.Model):
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if self._context.get('wubook_action', True) and \
|
||||
self.env['wubook'].is_valid_account() and \
|
||||
(vals.get('checkin') or vals.get('checkout') or
|
||||
vals.get('product_id') or vals.get('state')):
|
||||
older_vals = []
|
||||
@@ -155,13 +154,13 @@ class HotelReservation(models.Model):
|
||||
|
||||
res = super(HotelReservation, self).write(vals)
|
||||
|
||||
vroom_avail_obj = self.env['hotel.room.type.availability']
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
for i in range(0, len(older_vals)):
|
||||
vroom_avail_obj.refresh_availability(
|
||||
room_type_avail_obj.refresh_availability(
|
||||
older_vals[i]['checkin'],
|
||||
older_vals[i]['checkout'],
|
||||
older_vals[i]['product_id'])
|
||||
vroom_avail_obj.refresh_availability(
|
||||
room_type_avail_obj.refresh_availability(
|
||||
new_vals[i]['checkin'],
|
||||
new_vals[i]['checkout'],
|
||||
new_vals[i]['product_id'])
|
||||
@@ -181,11 +180,10 @@ class HotelReservation(models.Model):
|
||||
'product_id': record.product_id.id,
|
||||
})
|
||||
res = super(HotelReservation, self).unlink()
|
||||
if self._context.get('wubook_action', True) and \
|
||||
self.env['wubook'].is_valid_account():
|
||||
vroom_avail_obj = self.env['hotel.room.type.availability']
|
||||
if self._context.get('wubook_action', True):
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
for record in vals:
|
||||
vroom_avail_obj.refresh_availability(
|
||||
room_type_avail_obj.refresh_availability(
|
||||
record['checkin'],
|
||||
record['checkout'],
|
||||
record['product_id'])
|
||||
@@ -204,7 +202,7 @@ class HotelReservation(models.Model):
|
||||
self.write({'to_read': True, 'to_assign': True})
|
||||
|
||||
res = super(HotelReservation, self).action_cancel()
|
||||
if waction and self.env['wubook'].is_valid_account():
|
||||
if waction:
|
||||
partner_id = self.env['res.users'].browse(self.env.uid).partner_id
|
||||
for record in self:
|
||||
# Only can cancel reservations created directly in wubook
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo import api, models, fields, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.queue_job.job import job, related_action
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
@@ -12,12 +13,6 @@ class ChannelHotelRoomType(models.Model):
|
||||
_inherits = {'hotel.room.type': 'odoo_id'}
|
||||
_description = 'Channel Hotel Room'
|
||||
|
||||
@api.depends('ota_capacity')
|
||||
@api.onchange('room_ids', 'room_type_ids')
|
||||
def _get_capacity(self):
|
||||
for rec in self:
|
||||
rec.ota_capacity = rec.get_capacity()
|
||||
|
||||
odoo_id = fields.Many2one(comodel_names='hotel.room.type',
|
||||
string='Room Type',
|
||||
required=True,
|
||||
@@ -55,7 +50,7 @@ class ChannelHotelRoomType(models.Model):
|
||||
self.name,
|
||||
self.ota_capacity,
|
||||
self.list_price,
|
||||
self.max_real_rooms)
|
||||
self.total_rooms_count)
|
||||
if channel_room_id:
|
||||
self.write({
|
||||
'channel_room_id': channel_room_id,
|
||||
@@ -78,7 +73,7 @@ class ChannelHotelRoomType(models.Model):
|
||||
self.name,
|
||||
self.ota_capacity,
|
||||
self.list_price,
|
||||
self.max_real_rooms,
|
||||
self.total_rooms_count,
|
||||
self.channel_short_code)
|
||||
except ValidationError as e:
|
||||
self.create_issue('room', "Can't modify room on channel", "sss")
|
||||
@@ -112,6 +107,10 @@ class HotelRoomType(models.Model):
|
||||
inverse_name='odoo_id',
|
||||
string='Hotel Channel Connector Bindings')
|
||||
|
||||
@api.onchange('room_ids')
|
||||
def _get_capacity(self):
|
||||
for rec in self:
|
||||
rec.channel_bind_ids.ota_capacity = rec.get_capacity()
|
||||
|
||||
@api.multi
|
||||
def get_restrictions(self, date):
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from datetime import timedelta
|
||||
from odoo import api, models, fields
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.queue_job.job import job, related_action
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
from odoo.addons.hotel_channel_connector.components.backend_adapter import (
|
||||
DEFAULT_WUBOOK_DATE_FORMAT)
|
||||
|
||||
class ChannelHotelRoomTypeAvailability(models.Model):
|
||||
_name = 'channel.hotel.room.type.availability'
|
||||
@@ -14,8 +19,8 @@ class ChannelHotelRoomTypeAvailability(models.Model):
|
||||
|
||||
@api.model
|
||||
def _default_channel_max_avail(self):
|
||||
if self.room_type_id:
|
||||
return self.room_type_id.max_real_rooms
|
||||
if self.odoo_id.room_type_id:
|
||||
return self.odoo_id.room_type_id.total_rooms_count
|
||||
return -1
|
||||
|
||||
odoo_id = fields.Many2one(comodel_names='product.pricelist',
|
||||
@@ -31,10 +36,10 @@ class ChannelHotelRoomTypeAvailability(models.Model):
|
||||
@api.constrains('channel_max_avail')
|
||||
def _check_wmax_avail(self):
|
||||
for record in self:
|
||||
if record.channel_max_avail > record.room_type_id.total_rooms_count:
|
||||
if record.channel_max_avail > record.odoo_id.room_type_id.total_rooms_count:
|
||||
raise ValidationError(_("max avail for channel can't be high \
|
||||
than toal rooms \
|
||||
count: %d") % record.room_type_id.total_rooms_count)
|
||||
count: %d") % record.odoo_id.room_type_id.total_rooms_count)
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@related_action(action='related_action_unwrap_binding')
|
||||
@@ -44,12 +49,12 @@ class ChannelHotelRoomTypeAvailability(models.Model):
|
||||
if self._context.get('channel_action', True):
|
||||
with self.backend_id.work_on(self._name) as work:
|
||||
adapter = work.component(usage='backend.adapter')
|
||||
date_dt = date_utils.get_datetime(self.date)
|
||||
date_dt = fields.Date.from_string(self.date)
|
||||
adapter.update_availability([{
|
||||
'id': self.room_type_id.channel_room_id,
|
||||
'id': self.odoo_id.room_type_id.channel_room_id,
|
||||
'days': [{
|
||||
'date': date_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
'avail': self.avail,
|
||||
'avail': self.odoo_id.avail,
|
||||
}],
|
||||
}])
|
||||
|
||||
@@ -63,10 +68,10 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
|
||||
@api.constrains('avail')
|
||||
def _check_avail(self):
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
issue_obj = self.env['hotel.channel.connector.issue']
|
||||
for record in self:
|
||||
cavail = len(vroom_obj.check_availability_room(
|
||||
cavail = len(room_type_obj.check_availability_room(
|
||||
record.date,
|
||||
record.date,
|
||||
room_type_id=record.room_type_id.id))
|
||||
@@ -79,60 +84,61 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
\n[%s]\nInput: %d\Limit: %d") % (record.room_type_id.name,
|
||||
record.avail,
|
||||
record),
|
||||
'wid': record.room_type_id.wrid,
|
||||
'channel_id': record.room_type_id.channel_bind_ids[0].channel_plan_id,
|
||||
'date_start': record.date,
|
||||
'date_end': record.date,
|
||||
})
|
||||
# Auto-Fix wubook availability
|
||||
self._event('on_fix_channel_availability').notify(record)
|
||||
return super(HotelVirtualRoomAvailability, self)._check_avail()
|
||||
return super(HotelRoomTypeAvailability, self)._check_avail()
|
||||
|
||||
@api.onchange('room_type_id')
|
||||
def onchange_room_type_id(self):
|
||||
if self.room_type_id:
|
||||
self.channel_max_avail = self.room_type_id.max_real_rooms
|
||||
self.channel_max_avail = self.room_type_id.total_rooms_count
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if self._context.get('channel_action', True):
|
||||
vals.update({'channel_pushed': False})
|
||||
return super(HotelVirtualRoomAvailability, self).write(vals)
|
||||
return super(HotelRoomTypeAvailability, self).write(vals)
|
||||
|
||||
@api.model
|
||||
def refresh_availability(self, checkin, checkout, product_id):
|
||||
date_start = date_utils.get_datetime(checkin)
|
||||
date_start = fields.Date.from_string(checkin)
|
||||
date_end = fields.Date.from_string(checkout)
|
||||
# Not count end day of the reservation
|
||||
date_diff = date_utils.date_diff(checkin, checkout, hours=False)
|
||||
date_diff = (date_end - date_start).days
|
||||
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
|
||||
vrooms = vroom_obj.search([
|
||||
room_types = room_type_obj.search([
|
||||
('room_ids.product_id', '=', product_id)
|
||||
])
|
||||
for vroom in vrooms:
|
||||
if vroom.channel_room_id:
|
||||
for room_type in room_types:
|
||||
if room_type.channel_room_id:
|
||||
for i in range(0, date_diff):
|
||||
ndate_dt = date_start + timedelta(days=i)
|
||||
ndate_str = ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
avail = len(vroom_obj.check_availability_room(
|
||||
avail = len(room_type_obj.check_availability_room(
|
||||
ndate_str,
|
||||
ndate_str,
|
||||
room_type_id=vroom.id))
|
||||
max_avail = vroom.max_real_rooms
|
||||
vroom_avail_id = room_type_avail_obj.search([
|
||||
('room_type_id', '=', vroom.id),
|
||||
room_type_id=room_type.id))
|
||||
max_avail = room_type.total_rooms_count
|
||||
room_type_avail_id = room_type_avail_obj.search([
|
||||
('room_type_id', '=', room_type.id),
|
||||
('date', '=', ndate_str)], limit=1)
|
||||
if vroom_avail_id and vroom_avail_id.channel_max_avail >= 0:
|
||||
max_avail = vroom_avail_id.channel_max_avail
|
||||
if room_type_avail_id and room_type_avail_id.channel_max_avail >= 0:
|
||||
max_avail = room_type_avail_id.channel_max_avail
|
||||
avail = max(
|
||||
min(avail, vroom.total_rooms_count, max_avail), 0)
|
||||
min(avail, room_type.total_rooms_count, max_avail), 0)
|
||||
|
||||
if vroom_avail_id:
|
||||
vroom_avail_id.write({'avail': avail})
|
||||
if room_type_avail_id:
|
||||
room_type_avail_id.write({'avail': avail})
|
||||
else:
|
||||
room_type_avail_obj.create({
|
||||
'room_type_id': vroom.id,
|
||||
'room_type_id': room_type.id,
|
||||
'date': ndate_str,
|
||||
'avail': avail,
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.queue_job.job import job, related_action
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
@@ -43,9 +44,7 @@ class ChannelHotelRoomTypeRestriction(models.Model):
|
||||
with self.backend_id.work_on(self._name) as work:
|
||||
adapter = work.component(usage='backend.adapter')
|
||||
try:
|
||||
adapter.rename_rplan(
|
||||
self.channel_plan_id,
|
||||
self.name)
|
||||
adapter.rename_rplan(self.channel_plan_id, self.name)
|
||||
except ValidationError as e:
|
||||
self.create_issue('room', "Can't update restriction plan name on channel", "sss")
|
||||
|
||||
@@ -81,12 +80,12 @@ class HotelRoomTypeRestriction(models.Model):
|
||||
@api.multi
|
||||
@api.depends('name')
|
||||
def name_get(self):
|
||||
vroom_restriction_obj = self.env['hotel.room.type.restriction']
|
||||
org_names = super(HotelVirtualRoomRestriction, self).name_get()
|
||||
room_type_restriction_obj = self.env['hotel.room.type.restriction']
|
||||
org_names = super(HotelRoomTypeRestriction, self).name_get()
|
||||
names = []
|
||||
for name in org_names:
|
||||
restriction_id = vroom_restriction_obj.browse(name[0])
|
||||
if restriction_id.wpid:
|
||||
restriction_id = room_type_restriction_obj.browse(name[0])
|
||||
if restriction_id.channel_bind_ids.channel_plan_id:
|
||||
names.append((name[0], '%s (WuBook)' % name[1]))
|
||||
else:
|
||||
names.append((name[0], name[1]))
|
||||
@@ -98,7 +97,7 @@ class ChannelBindingHotelRoomTypeRestrictionListener(Component):
|
||||
_apply_on = ['channel.hotel.room.type.restriction']
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
def on_record_write(self, record, fields=None):
|
||||
def on_record_create(self, record, fields=None):
|
||||
record.with_delay(priority=20).create_plan()
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, fields, api
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ class ProductPricelistItem(models.Model):
|
||||
|
||||
is_channel_pushed = fields.Boolean("WuBook Pushed", default=True, readonly=True,
|
||||
old_name='wpushed')
|
||||
is_daily_plan = fields.Boolean(related='pricelist_id.wdaily', readonly=True,
|
||||
is_daily_plan = fields.Boolean(related='pricelist_id.channel_bind_ids.is_daily_plan', readonly=True,
|
||||
old_name='wdaily')
|
||||
|
||||
@api.constrains('fixed_price')
|
||||
def _check_fixed_price(self):
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
for record in self:
|
||||
vroom = vroom_obj.search([
|
||||
room_type = room_type_obj.search([
|
||||
('product_id.product_tmpl_id', '=', record.product_tmpl_id.id)
|
||||
], limit=1)
|
||||
if vroom and vroom.channel_room_id and record.compute_price == 'fixed' \
|
||||
if room_type and room_type.channel_room_id and record.compute_price == 'fixed' \
|
||||
and record.fixed_price <= 0.0:
|
||||
raise ValidationError(_("Price need be greater than zero"))
|
||||
|
||||
@@ -29,12 +29,12 @@ class ProductPricelistItem(models.Model):
|
||||
if self._context.get('channel_action', True):
|
||||
pricelist_id = self.env['product.pricelist'].browse(
|
||||
vals.get('pricelist_id'))
|
||||
vroom = self.env['hotel.virtual.room'].search([
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=',
|
||||
vals.get('product_tmpl_id')),
|
||||
('channel_room_id', '!=', False)
|
||||
])
|
||||
if vroom and pricelist_id.channel_plan_id:
|
||||
if room_type and pricelist_id.channel_plan_id:
|
||||
vals.update({'is_channel_pushed': False})
|
||||
return super(ProductPricelistItem, self).create(vals)
|
||||
|
||||
@@ -47,10 +47,10 @@ class ProductPricelistItem(models.Model):
|
||||
vals.get('pricelist_id') else record.pricelist_id
|
||||
product_tmpl_id = vals.get('product_tmpl_id') or \
|
||||
record.product_tmpl_id.id
|
||||
vroom = self.env['hotel.virtual.room'].search([
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id),
|
||||
('channel_room_id', '!=', False),
|
||||
])
|
||||
if vroom and pricelist_id.channel_plan_id:
|
||||
if room_type and pricelist_id.channel_plan_id:
|
||||
vals.update({'is_channel_pushed': False})
|
||||
return super(ProductPricelistItem, self).write(vals)
|
||||
|
||||
@@ -7,7 +7,7 @@ from openerp import models, fields, api
|
||||
class ReservationRestrictionItem(models.Model):
|
||||
_inherit = 'hotel.room.type.restriction.item'
|
||||
|
||||
channel_pushed = fields.Boolean("WuBook Pushed", default=False, readonly=True,
|
||||
channel_pushed = fields.Boolean("Channel Pushed", default=False, readonly=True,
|
||||
old_name='wpushed')
|
||||
|
||||
@api.onchange('date_start')
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.queue_job.job import job, related_action
|
||||
from odoo.addons.component.core import Component
|
||||
from odoo.addons.component_event import skip_if
|
||||
@@ -82,13 +83,15 @@ class ProductPricelist(models.Model):
|
||||
@api.multi
|
||||
@api.depends('name')
|
||||
def name_get(self):
|
||||
self.ensure_one()
|
||||
pricelist_obj = self.env['product.pricelist']
|
||||
org_names = super(ProductPricelist, self).name_get()
|
||||
names = []
|
||||
for name in org_names:
|
||||
priclist_id = pricelist_obj.browse(name[0])
|
||||
if priclist_id.wpid:
|
||||
names.append((name[0], '%s (WuBook)' % name[1]))
|
||||
if any(priclist_id.channel_bind_ids) and \
|
||||
priclist_id.channel_bind_ids[0].channel_plan_id:
|
||||
names.append((name[0], '%s (Channel)' % name[1]))
|
||||
else:
|
||||
names.append((name[0], name[1]))
|
||||
return names
|
||||
@@ -99,7 +102,7 @@ class ChannelBindingProductPricelistListener(Component):
|
||||
_apply_on = ['channel.product.pricelist']
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
def on_record_write(self, record, fields=None):
|
||||
def on_record_create(self, record, fields=None):
|
||||
record.with_delay(priority=20).create_plan()
|
||||
|
||||
@skip_if(lambda self, record, **kwargs: self.no_connector_export(record))
|
||||
|
||||
@@ -5,9 +5,8 @@ import os
|
||||
import binascii
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from odoo.addons.hotel import date_utils
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -41,7 +40,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
def resync(self):
|
||||
self.ensure_one()
|
||||
|
||||
now_utc_dt = date_utils.now()
|
||||
now_utc_dt = fields.Date.now()
|
||||
now_utc_str = now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
# Reset Issues
|
||||
@@ -56,29 +55,29 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
})
|
||||
if wubook_obj.init_connection():
|
||||
ir_seq_obj = self.env['ir.sequence']
|
||||
vrooms = self.env['hotel.room.type'].search([])
|
||||
for vroom in vrooms:
|
||||
room_types = self.env['hotel.room.type'].search([])
|
||||
for room_type in room_types:
|
||||
shortcode = ir_seq_obj.next_by_code('hotel.room.type')[:4]
|
||||
channel_room_id = wubook_obj.create_room(
|
||||
shortcode,
|
||||
vroom.name,
|
||||
vroom.wcapacity,
|
||||
vroom.list_price,
|
||||
vroom.max_real_rooms
|
||||
room_type.name,
|
||||
room_type.wcapacity,
|
||||
room_type.list_price,
|
||||
room_type.total_rooms_count
|
||||
)
|
||||
if channel_room_id:
|
||||
vroom.with_context(wubook_action=False).write({
|
||||
room_type.with_context(wubook_action=False).write({
|
||||
'channel_room_id': channel_room_id,
|
||||
'wscode': shortcode,
|
||||
})
|
||||
else:
|
||||
vroom.with_context(wubook_action=False).write({
|
||||
room_type.with_context(wubook_action=False).write({
|
||||
'channel_room_id': '',
|
||||
'wscode': '',
|
||||
})
|
||||
# Create Restrictions
|
||||
vroom_rest_obj = self.env['hotel.room.type.restriction']
|
||||
restriction_ids = vroom_rest_obj.search([])
|
||||
room_type_rest_obj = self.env['hotel.room.type.restriction']
|
||||
restriction_ids = room_type_rest_obj.search([])
|
||||
for restriction in restriction_ids:
|
||||
if restriction.wpid != '0':
|
||||
channel_plan_id = wubook_obj.create_rplan(restriction.name)
|
||||
@@ -88,7 +87,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
# Create Pricelist
|
||||
pricelist_ids = self.env['product.pricelist'].search([])
|
||||
for pricelist in pricelist_ids:
|
||||
channel_plan_id = wubook_obj.create_plan(pricelist.name, pricelist.wdaily)
|
||||
channel_plan_id = wubook_obj.create_plan(pricelist.name, pricelist.is_daily_plan)
|
||||
pricelist.write({
|
||||
'channel_plan_id': channel_plan_id or ''
|
||||
})
|
||||
@@ -115,13 +114,13 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
|
||||
# Get Parity Models
|
||||
pricelist_id = int(self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id'))
|
||||
'res.config.settings', 'parity_pricelist_id'))
|
||||
restriction_id = int(self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_restrictions_id'))
|
||||
'res.config.settings', 'parity_restrictions_id'))
|
||||
|
||||
vroom_restr_it_obj = self.env['hotel.room.type.restriction.item']
|
||||
room_type_restr_it_obj = self.env['hotel.room.type.restriction.item']
|
||||
# Secure Wubook Input
|
||||
restriction_item_ids = vroom_restr_it_obj.search([
|
||||
restriction_item_ids = room_type_restr_it_obj.search([
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('date_start', '<', now_utc_str),
|
||||
])
|
||||
@@ -130,7 +129,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
'wpushed': True
|
||||
})
|
||||
# Put to push restrictions
|
||||
restriction_item_ids = vroom_restr_it_obj.search([
|
||||
restriction_item_ids = room_type_restr_it_obj.search([
|
||||
('restriction_id', '=', restriction_id),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('wpushed', '=', True),
|
||||
|
||||
@@ -123,10 +123,10 @@ class TestHotelWubook(TestHotel):
|
||||
rooms = []
|
||||
rooms_occu = []
|
||||
booked_rooms = []
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
max_persons = 0
|
||||
for k_room, v_room in rinfo.iteritems():
|
||||
vroom = vroom_obj.search([
|
||||
room_type = room_type_obj.search([
|
||||
('wrid', '=', k_room)
|
||||
], limit=1)
|
||||
# Generate Rooms
|
||||
@@ -152,7 +152,7 @@ class TestHotelWubook(TestHotel):
|
||||
booked_rooms.append({
|
||||
'ancillary': {
|
||||
'channel_room_id': 1,
|
||||
'channel_room_name': vroom.name,
|
||||
'channel_room_name': room_type.name,
|
||||
'addons': [],
|
||||
'guests': val
|
||||
},
|
||||
@@ -240,20 +240,20 @@ class TestHotelWubook(TestHotel):
|
||||
super(TestHotelWubook, cls).setUpClass()
|
||||
|
||||
# Update Test Virtual Rooms
|
||||
cls.hotel_vroom_budget.write({
|
||||
cls.hotel_room_type_budget.write({
|
||||
'wcapacity': 1,
|
||||
'wrid': 3000,
|
||||
'wscode': 'T001',
|
||||
})
|
||||
cls.hotel_vroom_special.write({
|
||||
cls.hotel_room_type_special.write({
|
||||
'wcapacity': 2,
|
||||
'wrid': 3001,
|
||||
'wscode': 'T002',
|
||||
})
|
||||
|
||||
# Update Restriction
|
||||
vroom_restr_obj = cls.env['hotel.room.type.restriction']
|
||||
default_restriction = vroom_restr_obj.search([
|
||||
room_type_restr_obj = cls.env['hotel.room.type.restriction']
|
||||
default_restriction = room_type_restr_obj.search([
|
||||
('wpid', '=', '0')
|
||||
], limit=1)
|
||||
if default_restriction:
|
||||
|
||||
@@ -33,7 +33,7 @@ class TestHotelCalendarManagement(TestHotelWubook):
|
||||
def test_save_changes(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
vrooms = (self.hotel_vroom_budget,)
|
||||
room_types = (self.hotel_room_type_budget,)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
@@ -43,7 +43,7 @@ class TestHotelCalendarManagement(TestHotelWubook):
|
||||
cprices = {}
|
||||
for k_item, v_item in enumerate(prices):
|
||||
ndate_utc_dt = now_utc_dt + timedelta(days=k_item)
|
||||
cprices.setdefault(self.hotel_vroom_budget.id, []).append({
|
||||
cprices.setdefault(self.hotel_room_type_budget.id, []).append({
|
||||
'date': ndate_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'price': v_item
|
||||
})
|
||||
@@ -61,7 +61,7 @@ class TestHotelCalendarManagement(TestHotelWubook):
|
||||
crestrictions = {}
|
||||
for i in range(0, 4):
|
||||
ndate_utc_dt = now_utc_dt + timedelta(days=i)
|
||||
crestrictions.setdefault(self.hotel_vroom_budget.id, []).append({
|
||||
crestrictions.setdefault(self.hotel_room_type_budget.id, []).append({
|
||||
'date': ndate_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'closed_arrival': restrictions['closed_arrival'][i],
|
||||
'max_stay': restrictions['max_stay'][i],
|
||||
@@ -78,7 +78,7 @@ class TestHotelCalendarManagement(TestHotelWubook):
|
||||
for k_item, v_item in enumerate(avails):
|
||||
ndate_utc_dt = now_utc_dt + timedelta(days=k_item)
|
||||
ndate_dt = date_utils.dt_as_timezone(ndate_utc_dt, self.tz_hotel)
|
||||
cavails.setdefault(self.hotel_vroom_budget.id, []).append({
|
||||
cavails.setdefault(self.hotel_room_type_budget.id, []).append({
|
||||
'date': ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
'avail': v_item,
|
||||
'no_ota': False,
|
||||
@@ -100,16 +100,16 @@ class TestHotelCalendarManagement(TestHotelWubook):
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
|
||||
for vroom in vrooms:
|
||||
for room_type in room_types:
|
||||
for k_pr, v_pr in hcal_data['availability'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
if k_pr == room_type.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(v_info['avail'],
|
||||
avails[k_info],
|
||||
"Hotel Calendar Management \
|
||||
Availability doesn't match!")
|
||||
for k_pr, v_pr in hcal_data['restrictions'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
if k_pr == room_type.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(v_info['min_stay'],
|
||||
restrictions['min_stay'][k_info],
|
||||
@@ -145,7 +145,7 @@ class TestHotelCalendarManagement(TestHotelWubook):
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
for k_pr, v_pr in hcal_data['prices'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
if k_pr == room_type.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(v_info['price'],
|
||||
prices[k_info], "Hotel Calendar \
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestHotelFolio(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class TestHotelFolio(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class TestHotelFolio(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestHotelReservation(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1], # 1 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class TestHotelReservation(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1], # 1 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class TestHotelReservation(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1], # 1 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class TestHotelReservation(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1], # 1 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
|
||||
@@ -32,42 +32,42 @@ from .common import TestHotelWubook
|
||||
class TestHotelVirtualRoom(TestHotelWubook):
|
||||
|
||||
def test_get_capacity(self):
|
||||
self.assertEqual(self.hotel_vroom_budget.wcapacity,
|
||||
self.assertEqual(self.hotel_room_type_budget.wcapacity,
|
||||
1,
|
||||
"Invalid wcapacity")
|
||||
|
||||
def test_check_wcapacity(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.hotel_vroom_budget.sudo(self.user_hotel_manager).write({
|
||||
self.hotel_room_type_budget.sudo(self.user_hotel_manager).write({
|
||||
'wcapacity': 0
|
||||
})
|
||||
|
||||
def test_check_wscode(self):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.hotel_vroom_budget.sudo(self.user_hotel_manager).write({
|
||||
self.hotel_room_type_budget.sudo(self.user_hotel_manager).write({
|
||||
'wscode': 'abcdefg'
|
||||
})
|
||||
|
||||
def test_get_restrictions(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
rests = self.hotel_vroom_budget.sudo(
|
||||
rests = self.hotel_room_type_budget.sudo(
|
||||
self.user_hotel_manager).get_restrictions(
|
||||
now_utc_dt.strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT))
|
||||
self.assertTrue(any(rests), "Restrictions not found")
|
||||
|
||||
def test_import_rooms(self):
|
||||
self.hotel_vroom_budget.sudo(self.user_hotel_manager).import_rooms()
|
||||
self.hotel_room_type_budget.sudo(self.user_hotel_manager).import_rooms()
|
||||
|
||||
def test_create(self):
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
vroom = vroom_obj.sudo(self.user_hotel_manager).create({
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
room_type = room_type_obj.sudo(self.user_hotel_manager).create({
|
||||
'name': 'Budget Room',
|
||||
'virtual_code': '001',
|
||||
'list_price': 50,
|
||||
'wrid': 1234
|
||||
})
|
||||
vroom.unlink()
|
||||
room_type.unlink()
|
||||
|
||||
def test_unlink(self):
|
||||
self.hotel_vroom_budget.sudo(self.user_hotel_manager).unlink()
|
||||
self.hotel_room_type_budget.sudo(self.user_hotel_manager).unlink()
|
||||
|
||||
@@ -33,7 +33,7 @@ class TestProductPricelistItem(TestHotelWubook):
|
||||
def test_create(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
day_utc_dt = now_utc_dt + timedelta(days=20)
|
||||
budget_product_id = self.hotel_vroom_budget.product_id
|
||||
budget_product_id = self.hotel_room_type_budget.product_id
|
||||
pr_item_obj = self.env['product.pricelist.item']
|
||||
|
||||
parity_pricelist = self.env['product.pricelist'].browse([
|
||||
@@ -54,7 +54,7 @@ class TestProductPricelistItem(TestHotelWubook):
|
||||
def test_write(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
day_utc_dt = now_utc_dt + timedelta(days=20)
|
||||
budget_product_id = self.hotel_vroom_budget.product_id
|
||||
budget_product_id = self.hotel_room_type_budget.product_id
|
||||
pr_item_obj = self.env['product.pricelist.item']
|
||||
|
||||
parity_pricelist = self.env['product.pricelist'].browse([
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestResPartner(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class TestResPartner(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_1,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ class TestVirtualRoomAvailability(TestHotelWubook):
|
||||
def test_write(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
day_utc_dt = now_utc_dt + timedelta(days=1)
|
||||
vroom_avail_obj = self.env['hotel.room.type.availability']
|
||||
avail = vroom_avail_obj.search([
|
||||
('room_type_id', '=', self.hotel_vroom_budget.id),
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
avail = room_type_avail_obj.search([
|
||||
('room_type_id', '=', self.hotel_room_type_budget.id),
|
||||
('date', '=', now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
], limit=1)
|
||||
avail.write({
|
||||
|
||||
@@ -49,7 +49,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1], # 1 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1, 1], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -162,7 +162,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class TestWubook(TestHotelWubook):
|
||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class TestWubook(TestHotelWubook):
|
||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -253,7 +253,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -280,7 +280,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -292,7 +292,7 @@ class TestWubook(TestHotelWubook):
|
||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -320,7 +320,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0, 20.0, 17.0]
|
||||
}
|
||||
@@ -377,7 +377,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [3],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -394,7 +394,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2, 1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -422,7 +422,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -434,7 +434,7 @@ class TestWubook(TestHotelWubook):
|
||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -446,7 +446,7 @@ class TestWubook(TestHotelWubook):
|
||||
DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -477,7 +477,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_special.wrid: {
|
||||
self.hotel_room_type_special.wrid: {
|
||||
'occupancy': [2], # 2 Reservation Line
|
||||
'dayprices': [15.0, 15.0] # 2 Days
|
||||
}
|
||||
@@ -502,7 +502,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -513,7 +513,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -524,7 +524,7 @@ class TestWubook(TestHotelWubook):
|
||||
checkin_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.partner_2,
|
||||
{
|
||||
self.hotel_vroom_budget.wrid: {
|
||||
self.hotel_room_type_budget.wrid: {
|
||||
'occupancy': [1],
|
||||
'dayprices': [15.0, 15.0]
|
||||
}
|
||||
@@ -552,11 +552,11 @@ class TestWubook(TestHotelWubook):
|
||||
checkout_utc_dt = checkin_utc_dt + timedelta(days=1)
|
||||
checkout_dt = date_utils.dt_as_timezone(checkout_utc_dt,
|
||||
self.tz_hotel)
|
||||
vroom_restr_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
room_type_restr_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
|
||||
vrooms = [self.hotel_vroom_budget, self.hotel_vroom_special]
|
||||
room_types = [self.hotel_room_type_budget, self.hotel_room_type_special]
|
||||
values = self.create_wubook_rooms_values(
|
||||
vrooms,
|
||||
room_types,
|
||||
[{
|
||||
'closed_arrival': 0,
|
||||
'booked': 0,
|
||||
@@ -587,9 +587,9 @@ class TestWubook(TestHotelWubook):
|
||||
checkout_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
values)
|
||||
|
||||
for vroom in vrooms:
|
||||
items = vroom_restr_item_obj.search([
|
||||
('room_type_id', '=', vroom.id),
|
||||
for room_type in room_types:
|
||||
items = room_type_restr_item_obj.search([
|
||||
('room_type_id', '=', room_type.id),
|
||||
('date_start',
|
||||
'>=', checkin_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('date_end',
|
||||
|
||||
@@ -28,9 +28,9 @@ class MassiveChangesWizard(models.TransientModel):
|
||||
_inherit = 'hotel.wizard.massive.changes'
|
||||
|
||||
@api.model
|
||||
def _get_availability_values(self, ndate, vroom, record):
|
||||
def _get_availability_values(self, ndate, room_type, record):
|
||||
vals = super(MassiveChangesWizard, self)._get_availability_values(
|
||||
ndate, vroom, record)
|
||||
ndate, room_type, record)
|
||||
vals.update({
|
||||
'wmax_avail': vals['avail']
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user