mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP][MIG][11.0] Hotel Improvements + Hotel Calendar
This commit is contained in:
@@ -50,9 +50,9 @@
|
||||
'views/reservation_restriction_views.xml',
|
||||
'views/reservation_restriction_item_views.xml',
|
||||
'views/hotel_reservation.xml',
|
||||
# 'views/virtual_room_views.xml',
|
||||
# 'views/room_type_views.xml',
|
||||
'views/cardex.xml',
|
||||
'views/virtual_room_availability.xml',
|
||||
'views/room_type_availability.xml',
|
||||
# 'views/hotel_dashboard.xml',
|
||||
'data/cron_jobs.xml',
|
||||
'data/records.xml',
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
% endif
|
||||
<br />
|
||||
% for rline in object.get_grouped_reservations_json('cancelled'):
|
||||
<strong>${rline['num']} x ${rline['virtual_room']['name']}
|
||||
<strong>${rline['num']} x ${rline['room_type']['name']}
|
||||
% if rline['childrens'] > 0:
|
||||
(${rline['adults']} Adults + ${rline['childrens']} Childrens)
|
||||
% else:
|
||||
|
||||
@@ -257,7 +257,7 @@
|
||||
<br />
|
||||
|
||||
% for rline in object.get_grouped_reservations_json('confirm'):
|
||||
<strong>${rline['num']} x ${rline['virtual_room']['name']}
|
||||
<strong>${rline['num']} x ${rline['room_type']['name']}
|
||||
% if rline['childrens'] > 0:
|
||||
(${rline['adults']} Adultos + ${rline['childrens']} Niños)
|
||||
% else:
|
||||
@@ -406,13 +406,13 @@
|
||||
<tr>
|
||||
<td class="h2" style="font-family: sans-serif; font-size: 18px; font-weight: bold; color: #C50967; padding: 0 0 0 0; text-transform: uppercase; letter-spacing: 0.5px;">Información de la habitación</td>
|
||||
</tr>
|
||||
% set vroom_ids = object.room_lines.filtered('to_send').mapped('virtual_room_id.id')
|
||||
% set vrooms = user.env['hotel.virtual.room'].browse(vroom_ids)
|
||||
% for vroom in vrooms:
|
||||
% set room_type_ids = object.room_lines.filtered('to_send').mapped('room_type_id.id')
|
||||
% set room_types = user.env['hotel.room.type'].browse(room_type_ids)
|
||||
% for room_type in room_types:
|
||||
<tr>
|
||||
% if vroom.name:
|
||||
% if room_type.name:
|
||||
<td align="justify" class="subheading" style="color: #555555">
|
||||
<strong>${vroom.name}</strong>
|
||||
<strong>${room_type.name}</strong>
|
||||
</td>
|
||||
% else:
|
||||
<td align="justify" class="subheading" style="color: #555555">
|
||||
|
||||
@@ -19,7 +19,7 @@ from . import inherit_account_invoice
|
||||
# from . import inherit_product_category
|
||||
from . import inherit_product_product
|
||||
from . import inherit_res_company
|
||||
# from . import virtual_room
|
||||
# from . import room_type
|
||||
from . import inherit_account_payment
|
||||
from . import hotel_room_type_restriction
|
||||
from . import hotel_room_type_restriction_item
|
||||
|
||||
@@ -10,7 +10,6 @@ from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
|
||||
|
||||
class CurrencyExchangeRate(models.Model):
|
||||
|
||||
_name = "currency.exchange"
|
||||
_description = "currency"
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class HotelFolio(models.Model):
|
||||
_name = 'hotel.folio'
|
||||
_description = 'Hotel Folio'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
|
||||
_order = 'id'
|
||||
|
||||
# @api.depends('invoice_lines.invoice_id.state', 'invoice_lines.quantity')
|
||||
def _get_invoice_qty(self):
|
||||
@@ -41,12 +45,6 @@ class HotelFolio(models.Model):
|
||||
def _amount_all(self):
|
||||
pass
|
||||
|
||||
_name = 'hotel.folio'
|
||||
_description = 'Hotel Folio'
|
||||
|
||||
_order = 'id'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
|
||||
|
||||
name = fields.Char('Folio Number', readonly=True, index=True,
|
||||
default=lambda self: _('New'))
|
||||
partner_id = fields.Many2one('res.partner',
|
||||
|
||||
@@ -16,6 +16,10 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelReservation(models.Model):
|
||||
_name = 'hotel.reservation'
|
||||
_description = 'Hotel Reservation'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
|
||||
_order = "last_updated_res desc, name"
|
||||
|
||||
def _get_default_checkin(self):
|
||||
folio = False
|
||||
@@ -110,11 +114,6 @@ class HotelReservation(models.Model):
|
||||
fields.Date.from_string(res.checkout) - fields.Date.from_string(res.checkin)
|
||||
).days
|
||||
|
||||
_name = 'hotel.reservation'
|
||||
_description = 'Hotel Reservation'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
|
||||
_order = "last_updated_res desc, name"
|
||||
|
||||
name = fields.Text('Reservation Description', required=True)
|
||||
|
||||
room_id = fields.Many2one('hotel.room', string='Room')
|
||||
@@ -312,9 +311,12 @@ class HotelReservation(models.Model):
|
||||
})
|
||||
for record in self:
|
||||
if record.compute_price_out_vals(vals):
|
||||
checkin = vals['checkin'] if 'checkin' in vals else record.checkin
|
||||
checkout = vals['checkout'] if 'checkout' in vals else record.checkout
|
||||
|
||||
days_diff = (
|
||||
fields.Date.from_string(record.checkout) - \
|
||||
fields.Date.from_string(record.checkin)
|
||||
fields.Date.from_string(checkout) - \
|
||||
fields.Date.from_string(checkin)
|
||||
).days
|
||||
record.update(record.prepare_reservation_lines(
|
||||
vals['checkin'],
|
||||
@@ -390,7 +392,7 @@ class HotelReservation(models.Model):
|
||||
'overbooking': self.overbooking,
|
||||
'price_unit': self.price_unit,
|
||||
'splitted': self.splitted,
|
||||
# 'virtual_room_id': self.virtual_room_id.id,
|
||||
# 'room_type_id': self.room_type_id.id,
|
||||
'room_type_id': self.room_type_id.id,
|
||||
}
|
||||
|
||||
@@ -419,7 +421,7 @@ class HotelReservation(models.Model):
|
||||
#Si el registro no existe, modificar room_type aunque ya esté establecido
|
||||
if not self.room_type_id:
|
||||
write_vals.update({'room_type_id': self.room_id.room_type_id.id})
|
||||
self.write(write_vals)
|
||||
self.update(write_vals)
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def onchange_partner_id(self):
|
||||
|
||||
@@ -7,6 +7,7 @@ from odoo import models, fields, api, _
|
||||
class HotelRoomAmenities(models.Model):
|
||||
_name = 'hotel.room.amenities'
|
||||
_description = 'Room amenities'
|
||||
|
||||
# The record's name
|
||||
name = fields.Char('Amenity Name', required=True)
|
||||
# Used for activate records
|
||||
|
||||
@@ -7,6 +7,7 @@ from odoo import models, fields, api, _
|
||||
class HotelRoomAmenitiesType(models.Model):
|
||||
_name = 'hotel.room.amenities.type'
|
||||
_description = 'Amenities Type'
|
||||
|
||||
# The record's name
|
||||
name = fields.Char('Amenity Name', required=True)
|
||||
# Used for activate records
|
||||
|
||||
@@ -10,8 +10,8 @@ class HotelRoomType(models.Model):
|
||||
"""
|
||||
_name = "hotel.room.type"
|
||||
_description = "Room Type"
|
||||
|
||||
_inherits = {'product.product': 'product_id'}
|
||||
|
||||
# Relationship between models
|
||||
product_id = fields.Many2one('product.product', 'Product Room Type',
|
||||
required=True, delegate=True,
|
||||
@@ -59,7 +59,7 @@ class HotelRoomType(models.Model):
|
||||
|
||||
@api.model
|
||||
# TODO Rename to check_availability_room_type
|
||||
def check_availability_virtual_room(self, dfrom, dto,
|
||||
def check_availability_room(self, dfrom, dto,
|
||||
room_type_id=False, notthis=[]):
|
||||
"""
|
||||
Check the avalability for an specific type of room
|
||||
|
||||
@@ -10,7 +10,7 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
_inherit = 'mail.thread'
|
||||
_name = 'hotel.room.type.availability'
|
||||
|
||||
# virtual_room_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
|
||||
# room_type_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
|
||||
# required=True, track_visibility='always',
|
||||
# ondelete='cascade')
|
||||
room_type_id = fields.Many2one('hotel.room.type', 'Room Type',
|
||||
@@ -34,7 +34,7 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
self.avail = 0
|
||||
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
cavail = len(room_type_obj.check_availability_virtual_room(
|
||||
cavail = len(room_type_obj.check_availability_room(
|
||||
self.date,
|
||||
self.date,
|
||||
room_type_id=self.room_type_id.id))
|
||||
@@ -44,7 +44,7 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
self.avail = max_avail
|
||||
|
||||
@api.constrains('date', 'room_type_id')
|
||||
def _check_date_virtual_room_id(self):
|
||||
def _check_date_room_type_id(self):
|
||||
count = self.search_count([
|
||||
('date', '=', self.date),
|
||||
('room_type_id', '=', self.room_type_id.id)
|
||||
|
||||
@@ -13,7 +13,7 @@ class HotelRoomTypeRestrictionItem(models.Model):
|
||||
restriction_id = fields.Many2one('hotel.room.type.restriction',
|
||||
'Restriction Plan', ondelete='cascade',
|
||||
index=True)
|
||||
# virtual_room_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
|
||||
# room_type_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
|
||||
# required=True, ondelete='cascade')
|
||||
room_type_id = fields.Many2one('hotel.room.type', 'Room Type',
|
||||
required=True, ondelete='cascade')
|
||||
@@ -21,8 +21,8 @@ class HotelRoomTypeRestrictionItem(models.Model):
|
||||
date_end = fields.Date("To")
|
||||
applied_on = fields.Selection([
|
||||
('1_global', 'Global'),
|
||||
# ('0_virtual_room', 'Virtual Room')], string="Apply On", required=True,
|
||||
# default='0_virtual_room',
|
||||
# ('0_room_type', 'Virtual Room')], string="Apply On", required=True,
|
||||
# default='0_room_type',
|
||||
('0_room_type', 'Room Type')], string="Apply On", required=True,
|
||||
default='0_room_type',
|
||||
help='Pricelist Item applicable on selected option')
|
||||
|
||||
@@ -8,7 +8,9 @@ from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class HotelService(models.Model):
|
||||
|
||||
_name = 'hotel.service'
|
||||
_description = 'Hotel Services and its charges'
|
||||
|
||||
@api.model
|
||||
def _service_checkin(self):
|
||||
if 'checkin' in self._context:
|
||||
@@ -30,9 +32,6 @@ class HotelService(models.Model):
|
||||
], limit=1)
|
||||
return False
|
||||
|
||||
_name = 'hotel.service'
|
||||
_description = 'Hotel Services and its charges'
|
||||
|
||||
name = fields.Char('Service description')
|
||||
# services in the hotel are products
|
||||
product_id = fields.Many2one('product.product', 'Service', required=True)
|
||||
|
||||
@@ -146,7 +146,7 @@ class HotelServiceLine(models.Model):
|
||||
'product_uom': self.product_id.uom_id,
|
||||
'price_unit': self.product_id.price,
|
||||
})
|
||||
self.write(write_vals)
|
||||
self.update(write_vals)
|
||||
|
||||
#~ self.price_unit = tax_obj._fix_tax_included_price(prod.price,
|
||||
#~ prod.taxes_id,
|
||||
|
||||
@@ -7,7 +7,6 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountPayment(models.Model):
|
||||
|
||||
_inherit = 'account.payment'
|
||||
|
||||
folio_id = fields.Many2one('hotel.folio', string='Folio')
|
||||
|
||||
@@ -20,12 +20,12 @@ access_hotel_order_call,hotel.order.call,sale.model_sale_order,hotel.group_hotel
|
||||
access_hotel_order_line_call,hotel.order.line.call,sale.model_sale_order_line,hotel.group_hotel_call,1,1,1,1
|
||||
access_hotel_order_line_user,hotel.order.line.user,sale.model_sale_order_line,hotel.group_hotel_user,1,1,1,1
|
||||
access_hotel_order_user,hotel.order.user,sale.model_sale_order,hotel.group_hotel_user,1,1,1,1
|
||||
access_hotel_restrictions_call,hotel.restriction. All,hotel.model_hotel_virtual_room_restriction,hotel.group_hotel_call,1,0,0,0
|
||||
access_hotel_restrictions_item_call,hotel.restriction.item.call,hotel.model_hotel_virtual_room_restriction_item,hotel.group_hotel_call,1,0,0,0
|
||||
access_hotel_restrictions_item_manager,hotel.restriction.item.manager,hotel.model_hotel_virtual_room_restriction_item,hotel.group_hotel_manager,1,1,1,1
|
||||
access_hotel_restrictions_item_user,hotel.restriction.item.user,hotel.model_hotel_virtual_room_restriction_item,hotel.group_hotel_user,1,0,0,0
|
||||
access_hotel_restrictions_manager,hotel.restriction.manager,hotel.model_hotel_virtual_room_restriction,hotel.group_hotel_manager,1,1,1,1
|
||||
access_hotel_restrictions_user,hotel.restriction.user,hotel.model_hotel_virtual_room_restriction,hotel.group_hotel_user,1,0,0,0
|
||||
access_hotel_restrictions_call,hotel.restriction. All,hotel.model_hotel_room_type_restriction,hotel.group_hotel_call,1,0,0,0
|
||||
access_hotel_restrictions_item_call,hotel.restriction.item.call,hotel.model_hotel_room_type_restriction_item,hotel.group_hotel_call,1,0,0,0
|
||||
access_hotel_restrictions_item_manager,hotel.restriction.item.manager,hotel.model_hotel_room_type_restriction_item,hotel.group_hotel_manager,1,1,1,1
|
||||
access_hotel_restrictions_item_user,hotel.restriction.item.user,hotel.model_hotel_room_type_restriction_item,hotel.group_hotel_user,1,0,0,0
|
||||
access_hotel_restrictions_manager,hotel.restriction.manager,hotel.model_hotel_room_type_restriction,hotel.group_hotel_manager,1,1,1,1
|
||||
access_hotel_restrictions_user,hotel.restriction.user,hotel.model_hotel_room_type_restriction,hotel.group_hotel_user,1,0,0,0
|
||||
access_hotel_room,hotel.room.user,model_hotel_room,hotel.group_hotel_user,1,0,0,0
|
||||
access_hotel_room_amenities,hotel.room_aminities.user,model_hotel_room_amenities,hotel.group_hotel_user,1,0,0,0
|
||||
access_hotel_room_amenities_call,hotel.room_aminities.call,model_hotel_room_amenities,hotel.group_hotel_call,1,0,0,0
|
||||
@@ -43,9 +43,9 @@ access_hotel_service_call,hotel_service.call,model_hotel_service,hotel.group_hot
|
||||
access_hotel_user reconcilie,hotel.user reconcilie,account.model_account_partial_reconcile,hotel.group_hotel_user,1,1,1,1
|
||||
access_hotel_user_account_full_reconcilie,hotel.user_account_full_reconcilie,account.model_account_full_reconcile,hotel.group_hotel_user,1,1,1,1
|
||||
access_hotel_user_user,hotel.user_res_user,auth_crypt.model_res_users,hotel.group_hotel_user,1,1,0,0
|
||||
access_hotel_virtual_room_availability_call,hotel.availability.call,hotel.model_hotel_virtual_room_availability,hotel.group_hotel_call,1,1,1,1
|
||||
access_hotel_virtual_room_availability_manager,hotel.availability.manager,hotel.model_hotel_virtual_room_availability,hotel.group_hotel_manager,1,1,1,1
|
||||
access_hotel_virtual_room_availability_user,hotel.availability.user,hotel.model_hotel_virtual_room_availability,hotel.group_hotel_user,1,1,1,1
|
||||
access_hotel_room_type_availability_call,hotel.availability.call,hotel.model_hotel_room_type_availability,hotel.group_hotel_call,1,1,1,1
|
||||
access_hotel_room_type_availability_manager,hotel.availability.manager,hotel.model_hotel_room_type_availability,hotel.group_hotel_manager,1,1,1,1
|
||||
access_hotel_room_type_availability_user,hotel.availability.user,hotel.model_hotel_room_type_availability,hotel.group_hotel_user,1,1,1,1
|
||||
access_product_category,product.category.user,product.model_product_category,hotel.group_hotel_user,1,0,0,0
|
||||
access_product_category_call,product.category.call,product.model_product_category,hotel.group_hotel_call,1,0,0,0
|
||||
access_product_category_manager,product.category.manager,product.model_product_category,hotel.group_hotel_manager,1,1,1,1
|
||||
|
||||
|
@@ -59,7 +59,7 @@ class TestHotel(TestMail):
|
||||
'checkin': checkin.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'checkout': checkout.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'folio_id': folio.id,
|
||||
'virtual_room_id': room.price_virtual_room.id,
|
||||
'room_type_id': room.price_room_type.id,
|
||||
'product_id': room.product_id.id,
|
||||
})
|
||||
self.assertTrue(
|
||||
@@ -171,14 +171,14 @@ class TestHotel(TestMail):
|
||||
cls.hotel_room_simple_100 = Rooms.create({
|
||||
'name': '100',
|
||||
'sale_price_type': 'vroom',
|
||||
'price_virtual_room': cls.hotel_vroom_budget.id,
|
||||
'price_room_type': cls.hotel_vroom_budget.id,
|
||||
'categ_id': cls.hotel_room_type_simple.cat_id.id,
|
||||
'capacity': 1,
|
||||
})
|
||||
cls.hotel_room_simple_101 = Rooms.create({
|
||||
'name': '101',
|
||||
'sale_price_type': 'vroom',
|
||||
'price_virtual_room': cls.hotel_vroom_budget.id,
|
||||
'price_room_type': cls.hotel_vroom_budget.id,
|
||||
'categ_id': cls.hotel_room_type_simple.cat_id.id,
|
||||
'capacity': 1,
|
||||
'sequence': 1,
|
||||
@@ -186,7 +186,7 @@ class TestHotel(TestMail):
|
||||
cls.hotel_room_double_200 = Rooms.create({
|
||||
'name': '200',
|
||||
'sale_price_type': 'vroom',
|
||||
'price_virtual_room': cls.hotel_vroom_special.id,
|
||||
'price_room_type': cls.hotel_vroom_special.id,
|
||||
'categ_id': cls.hotel_room_type_double.cat_id.id,
|
||||
'capacity': 2,
|
||||
})
|
||||
@@ -228,16 +228,16 @@ class TestHotel(TestMail):
|
||||
for i in range(0, len(v_vr)):
|
||||
ndate = now_utc_dt + timedelta(days=i)
|
||||
vroom_avail_obj.create({
|
||||
'virtual_room_id': k_vr,
|
||||
'room_type_id': k_vr,
|
||||
'avail': v_vr[i],
|
||||
'date': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
})
|
||||
vroom_rest_item_obj.create({
|
||||
'virtual_room_id': k_vr,
|
||||
'room_type_id': k_vr,
|
||||
'restriction_id': cls.parity_restrictions_id,
|
||||
'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
'applied_on': '0_virtual_room',
|
||||
'applied_on': '0_room_type',
|
||||
'min_stay': cls.restrictions_min_stay_tmp[k_vr][i],
|
||||
})
|
||||
pricelist_item_obj.create({
|
||||
|
||||
@@ -232,7 +232,7 @@ class TestHotelReservations(TestHotel):
|
||||
|
||||
# 5.0, 15.0, 15.0, 35.0, 35.0, 10.0, 10.0
|
||||
|
||||
vroom_prices = self.prices_tmp[self.hotel_room_double_200.price_virtual_room.id]
|
||||
vroom_prices = self.prices_tmp[self.hotel_room_double_200.price_room_type.id]
|
||||
org_reserv_start_utc_dt = now_utc_dt + timedelta(days=1)
|
||||
org_reserv_end_utc_dt = org_reserv_start_utc_dt + timedelta(days=2)
|
||||
folio = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
<field name="partner_id"/>
|
||||
<field name="splitted" invisible="1" />
|
||||
<field name="parent_reservation" invisible="1" />
|
||||
<!-- <field name="virtual_room_id" string="Reserved Room Type"/> -->
|
||||
<!-- <field name="room_type_id" string="Reserved Room Type"/> -->
|
||||
<field name="room_type_id" string="Reserved Room Type"/>
|
||||
<field name="nights" />
|
||||
<field name="adults" string="Persons"/>
|
||||
@@ -307,7 +307,7 @@
|
||||
<field name="name"/>
|
||||
<field name="adults"/>
|
||||
<field name="children"/>
|
||||
<!-- <field name="virtual_room_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
<!-- <field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'readonly':[('state','not in',('draft'))]}"/> -->
|
||||
<field name="channel_type" attrs="{'required':[('reservation_type','not in',('staff','out'))]}"/>
|
||||
</group>
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
<field name="name"/>
|
||||
<field name="adults"/>
|
||||
<field name="children"/>
|
||||
<!-- <field name="virtual_room_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
<!-- <field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'readonly':[('state','not in',('draft'))]}"/> -->
|
||||
<field name="room_type_id" on_change="1" options="{'no_create': True,'no_open': True}"
|
||||
attrs="{'readonly':[('state','not in',('draft'))]}"/>
|
||||
@@ -335,7 +335,7 @@
|
||||
/>
|
||||
<field name="partner_id"/>
|
||||
<field name="parent_reservation" invisible="1" />
|
||||
<!-- <field name="virtual_room_id" string="Reserved Room Type"/> -->
|
||||
<!-- <field name="room_type_id" string="Reserved Room Type"/> -->
|
||||
<field name="room_type_id" string="Reserved Unit Type" />
|
||||
<field name="nights" />
|
||||
<field name="adults" string="Persons"/>
|
||||
@@ -432,7 +432,7 @@
|
||||
/>
|
||||
<group expand="0" string="Group By">
|
||||
<!-- <filter string="Room Type" domain="[]"
|
||||
context="{'group_by':'virtual_room_id'}"/> -->
|
||||
context="{'group_by':'room_type_id'}"/> -->
|
||||
<filter string="Room Type" domain="[]"
|
||||
context="{'group_by':'room_type_id'}"/>
|
||||
<filter string="Creation Date" domain="[]"
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
</group>
|
||||
<group>
|
||||
<!-- <field name="sale_price_type" /> -->
|
||||
<!--field name="price_virtual_room_domain" invisible="1" /-->
|
||||
<!-- <field name="price_virtual_room" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'vroom')], 'required': [('sale_price_type', '=', 'vroom')]}" /> -->
|
||||
<!-- <field name="price_room_type" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'vroom')], 'required': [('sale_price_type', '=', 'vroom')]}" /> -->
|
||||
<!--field name="price_room_type_domain" invisible="1" /-->
|
||||
<!-- <field name="price_room_type" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'room_type')], 'required': [('sale_price_type', '=', 'room_type')]}" /> -->
|
||||
<!-- <field name="price_room_type" domain="[('room_ids.id', '=', active_id)]" attrs="{'invisible':[('sale_price_type', '!=', 'room_type')], 'required': [('sale_price_type', '=', 'room_type')]}" /> -->
|
||||
</group>
|
||||
<newline />
|
||||
<!-- <separator colspan='4' string="Customer Taxes" /> -->
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<form string="Restrictions">
|
||||
<group>
|
||||
<field name="applied_on" widget="radio"/>
|
||||
<!-- <field name="virtual_room_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/> -->
|
||||
<!-- <field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/> -->
|
||||
<field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_global']]}" required="True"/>
|
||||
</group>
|
||||
<group>
|
||||
@@ -43,7 +43,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Restrictions">
|
||||
<field name="applied_on"/>
|
||||
<!-- <field name="virtual_room_id" attrs="{'invisible':[['applied_on', '=', '1_virtual_room']]}"/> -->
|
||||
<!-- <field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '1_room_type']]}"/> -->
|
||||
<field name="room_type_id" attrs="{'invisible':[['applied_on', '=', '0_room_type']]}"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_end"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<field name="item_ids" nolabel="1">
|
||||
<tree string="Restriction Items">
|
||||
<field name="applied_on"/>
|
||||
<!-- <field name="virtual_room_id" attr="{'invisible':[['applied_on', '=', '1_virtual_room']]}"/> -->
|
||||
<!-- <field name="room_type_id" attr="{'invisible':[['applied_on', '=', '1_room_type']]}"/> -->
|
||||
<field name="room_type_id" attr="{'invisible':[['applied_on', '=', '0_room_type']]}"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_end"/>
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
<odoo>
|
||||
|
||||
<!-- FORM availability -->
|
||||
<record id="virtual_room_availability_view_form" model="ir.ui.view">
|
||||
<record id="room_type_availability_view_form" model="ir.ui.view">
|
||||
<field name="name">hotel.room.type.availability.form</field>
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Availability">
|
||||
<sheet>
|
||||
<group>
|
||||
<!-- <h1><field name="virtual_room_id" required="1"/></h1> -->
|
||||
<!-- <h1><field name="room_type_id" required="1"/></h1> -->
|
||||
<h1><field name="room_type_id" required="1"/></h1>
|
||||
</group>
|
||||
<group>
|
||||
@@ -28,12 +28,12 @@
|
||||
</record>
|
||||
|
||||
<!-- TREE restriction -->
|
||||
<record id="virtual_room_availability_view_tree" model="ir.ui.view">
|
||||
<record id="room_type_availability_view_tree" model="ir.ui.view">
|
||||
<field name="name">hotel.room.type.availability.tree</field>
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Restrictions">
|
||||
<!-- <field name="virtual_room_id" required="1"/> -->
|
||||
<!-- <field name="room_type_id" required="1"/> -->
|
||||
<field name="room_type_id" required="1"/>
|
||||
<field name="date" required="1"/>
|
||||
<field name="avail"/>
|
||||
@@ -44,7 +44,7 @@
|
||||
</record>
|
||||
|
||||
<!-- Action of reservation restriction -->
|
||||
<record model="ir.actions.act_window" id="virtual_room_availability_action">
|
||||
<record model="ir.actions.act_window" id="room_type_availability_action">
|
||||
<field name="name">Virtual Room Availability</field>
|
||||
<field name="res_model">hotel.room.type.availability</field>
|
||||
<field name="view_type">form</field>
|
||||
@@ -52,8 +52,8 @@
|
||||
</record>
|
||||
|
||||
<!-- MENUS -->
|
||||
<menuitem name="Availability" id="virtual_room_availability_menu"
|
||||
action="virtual_room_availability_action" sequence="22"
|
||||
<menuitem name="Availability" id="room_type_availability_menu"
|
||||
action="room_type_availability_action" sequence="22"
|
||||
parent="hotel.configuration_others"/>
|
||||
|
||||
</odoo>
|
||||
@@ -2,9 +2,9 @@
|
||||
<odoo>
|
||||
|
||||
<!-- FORM Virtual Room -->
|
||||
<record id="virtual_room_view_form" model="ir.ui.view">
|
||||
<field name="name">virtual.room.view.form</field>
|
||||
<field name="model">hotel.virtual.room</field>
|
||||
<record id="room_type_view_form" model="ir.ui.view">
|
||||
<field name="name">room.type.view.form</field>
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Virtual Room">
|
||||
<sheet>
|
||||
@@ -41,9 +41,9 @@
|
||||
</record>
|
||||
|
||||
<!-- TREE Virtual Room -->
|
||||
<record id="virtual_room_view_tree" model="ir.ui.view">
|
||||
<field name="name">virtual.room.view.tree</field>
|
||||
<field name="model">hotel.virtual.room</field>
|
||||
<record id="room_type_view_tree" model="ir.ui.view">
|
||||
<field name="name">room.type.view.tree</field>
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Virtual Rooms">
|
||||
<field name="name"/>
|
||||
@@ -57,16 +57,16 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="virtual_room_action_form">
|
||||
<record model="ir.actions.act_window" id="room_type_action_form">
|
||||
<field name="name">Virtual Rooms</field>
|
||||
<field name="res_model">hotel.virtual.room</field>
|
||||
<field name="res_model">hotel.room.type</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<!-- MENUS -->
|
||||
<menuitem name="Virtual rooms" id="virtual_room_menu"
|
||||
action="virtual_room_action_form" sequence="40"
|
||||
<menuitem name="Virtual rooms" id="room_type_menu"
|
||||
action="room_type_action_form" sequence="40"
|
||||
parent="hotel.menu_hotel_room"/>
|
||||
|
||||
</odoo>
|
||||
@@ -212,7 +212,7 @@ class Wizard(models.TransientModel):
|
||||
# show the checkin fields if a partner is selected
|
||||
if self.op_select_partner == 'S' and self.partner_id.id != False:
|
||||
write_vals.update({'checkin_mode': 1})
|
||||
self.write(write_vals)
|
||||
self.update(write_vals)
|
||||
|
||||
@api.onchange('op_select_partner')
|
||||
def onchange_op_select_partner(self):
|
||||
|
||||
@@ -32,7 +32,7 @@ class DuplicateReservationWizard(models.TransientModel):
|
||||
}))
|
||||
|
||||
# Check Input
|
||||
avails = hotel_room_type_obj.check_availability_virtual_room(
|
||||
avails = hotel_room_type_obj.check_availability_room(
|
||||
reservation_id.checkin,
|
||||
reservation_id.checkout,
|
||||
room_type_id=reservation_id.room_type_id.id)
|
||||
@@ -43,10 +43,10 @@ class DuplicateReservationWizard(models.TransientModel):
|
||||
There are no '%d' free rooms") % self.num)
|
||||
|
||||
for i in range(0, self.num):
|
||||
free_rooms = hotel_room_type_obj.check_availability_virtual_room(
|
||||
free_rooms = hotel_room_type_obj.check_availability_room(
|
||||
reservation_id.checkin,
|
||||
reservation_id.checkout,
|
||||
virtual_room_id=reservation_id.room_type_id.id)
|
||||
room_type_id=reservation_id.room_type_id.id)
|
||||
if any(free_rooms):
|
||||
new_reservation_id = hotel_reservation_obj.create({
|
||||
'room_id': free_rooms[0].id,
|
||||
|
||||
@@ -30,7 +30,7 @@ class MassiveChangesWizard(models.TransientModel):
|
||||
('0', 'Global'),
|
||||
('1', 'Virtual Room'),
|
||||
], string='Applied On', default='0')
|
||||
# virtual_room_ids = fields.Many2many('hotel.virtual.room',
|
||||
# room_type_ids = fields.Many2many('hotel.virtual.room',
|
||||
# string="Virtual Rooms")
|
||||
room_type_ids = fields.Many2many('hotel.room.type',
|
||||
string="Room Types")
|
||||
@@ -171,7 +171,7 @@ class MassiveChangesWizard(models.TransientModel):
|
||||
('date_start', '>=', ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('date_end', '<=', ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('restriction_id', '=', record.restriction_id.id),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
]
|
||||
|
||||
for room_type in room_types:
|
||||
@@ -189,7 +189,7 @@ class MassiveChangesWizard(models.TransientModel):
|
||||
'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
'restriction_id': record.restriction_id.id,
|
||||
'room_type_id': room_type.id,
|
||||
'applied_on': '0_virtual_room',
|
||||
'applied_on': '0_room_type',
|
||||
})
|
||||
hotel_room_type_re_it_obj.create(vals)
|
||||
|
||||
@@ -200,7 +200,7 @@ class MassiveChangesWizard(models.TransientModel):
|
||||
if record.change_no_ota:
|
||||
vals.update({'no_ota': record.no_ota})
|
||||
if record.change_avail:
|
||||
cavail = len(hotel_room_type_obj.check_availability_virtual_room(
|
||||
cavail = len(hotel_room_type_obj.check_availability_room(
|
||||
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
room_type_id=room_type.id))
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<group>
|
||||
<field name="section" required="1" />
|
||||
<field name="applied_on" required="1" />
|
||||
<!-- <field name="virtual_room_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" /> -->
|
||||
<!-- <field name="room_type_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" /> -->
|
||||
<field name="room_type_ids" widget="many2many_tags" attrs="{'invisible':[('applied_on', '!=', '1')], 'required':[('applied_on', '=', '1')]}" />
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
|
||||
@@ -64,7 +64,7 @@ class SplitReservationWizard(models.TransientModel):
|
||||
'splitted': True,
|
||||
'price_unit': tprice[1],
|
||||
'parent_reservation': parent_res.id,
|
||||
'virtual_room_id': parent_res.virtual_room_id.id,
|
||||
'room_type_id': parent_res.room_type_id.id,
|
||||
'discount': parent_res.discount,
|
||||
})
|
||||
reservation_copy = self.env['hotel.reservation'].create(vals)
|
||||
|
||||
@@ -9,8 +9,8 @@ from . import hotel_calendar_management
|
||||
from . import res_config
|
||||
from . import inherited_hotel_room
|
||||
from . import inherited_hotel_room_type
|
||||
from . import inherited_hotel_virtual_room_restriction_item
|
||||
from . import inherited_hotel_virtual_room_availability
|
||||
from . import inherited_hotel_room_type_restriction_item
|
||||
from . import inherited_hotel_room_type_availability
|
||||
from . import inherited_product_pricelist
|
||||
from . import inherited_hotel_folio
|
||||
from . import inherited_ir_default
|
||||
|
||||
@@ -35,11 +35,11 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def _get_availability_values(self, avail, vroom):
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
cavail = len(vroom_obj.check_availability_virtual_room(
|
||||
avail['date'], avail['date'], virtual_room_id=vroom.id))
|
||||
ravail = min(cavail, vroom.total_rooms_count, int(avail['avail']))
|
||||
def _get_availability_values(self, avail, room_type):
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
cavail = len(room_type_obj.check_availability_room(
|
||||
avail['date'], avail['date'], room_type_id=room_type.id))
|
||||
ravail = min(cavail, room_type.total_rooms_count, int(avail['avail']))
|
||||
vals = {
|
||||
'no_ota': avail['no_ota'],
|
||||
'avail': ravail,
|
||||
@@ -49,15 +49,15 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
@api.multi
|
||||
def save_changes(self, pricelist_id, restriction_id, pricelist,
|
||||
restrictions, availability):
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
product_pricelist_item_obj = self.env['product.pricelist.item']
|
||||
vroom_rest_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
vroom_avail_obj = self.env['hotel.room.type.availability']
|
||||
room_type_rest_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
|
||||
# Save Pricelist
|
||||
for k_price in pricelist.keys():
|
||||
vroom_id = vroom_obj.browse([int(k_price)])
|
||||
vroom_prod_tmpl_id = vroom_id.product_id.product_tmpl_id
|
||||
room_type_id = room_type_obj.browse([int(k_price)])
|
||||
room_type_prod_tmpl_id = room_type_id.product_id.product_tmpl_id
|
||||
for price in pricelist[k_price]:
|
||||
price_id = product_pricelist_item_obj.search([
|
||||
('date_start', '>=', price['date']),
|
||||
@@ -65,7 +65,7 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
('pricelist_id', '=', int(pricelist_id)),
|
||||
('applied_on', '=', '1_product'),
|
||||
('compute_price', '=', 'fixed'),
|
||||
('product_tmpl_id', '=', vroom_prod_tmpl_id.id),
|
||||
('product_tmpl_id', '=', room_type_prod_tmpl_id.id),
|
||||
], limit=1)
|
||||
vals = self._get_prices_values(price)
|
||||
if not price_id:
|
||||
@@ -75,7 +75,7 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
'pricelist_id': int(pricelist_id),
|
||||
'applied_on': '1_product',
|
||||
'compute_price': 'fixed',
|
||||
'product_tmpl_id': vroom_prod_tmpl_id.id,
|
||||
'product_tmpl_id': room_type_prod_tmpl_id.id,
|
||||
})
|
||||
price_id = product_pricelist_item_obj.create(vals)
|
||||
else:
|
||||
@@ -84,12 +84,12 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
# Save Restrictions
|
||||
for k_res in restrictions.keys():
|
||||
for restriction in restrictions[k_res]:
|
||||
res_id = vroom_rest_item_obj.search([
|
||||
res_id = room_type_rest_item_obj.search([
|
||||
('date_start', '>=', restriction['date']),
|
||||
('date_end', '<=', restriction['date']),
|
||||
('restriction_id', '=', int(restriction_id)),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('virtual_room_id', '=', int(k_res)),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('room_type_id', '=', int(k_res)),
|
||||
], limit=1)
|
||||
vals = self._get_restrictions_values(restriction)
|
||||
if not res_id:
|
||||
@@ -97,28 +97,28 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
'date_start': restriction['date'],
|
||||
'date_end': restriction['date'],
|
||||
'restriction_id': int(restriction_id),
|
||||
'applied_on': '0_virtual_room',
|
||||
'virtual_room_id': int(k_res),
|
||||
'applied_on': '0_room_type',
|
||||
'room_type_id': int(k_res),
|
||||
})
|
||||
res_id = vroom_rest_item_obj.create(vals)
|
||||
res_id = room_type_rest_item_obj.create(vals)
|
||||
else:
|
||||
res_id.write(vals)
|
||||
|
||||
# Save Availability
|
||||
for k_avail in availability.keys():
|
||||
vroom_id = vroom_obj.browse(int(k_avail))
|
||||
room_type_id = room_type_obj.browse(int(k_avail))
|
||||
for avail in availability[k_avail]:
|
||||
vals = self._get_availability_values(avail, vroom_id)
|
||||
avail_id = vroom_avail_obj.search([
|
||||
vals = self._get_availability_values(avail, room_type_id)
|
||||
avail_id = room_type_avail_obj.search([
|
||||
('date', '=', avail['date']),
|
||||
('virtual_room_id', '=', vroom_id.id),
|
||||
('room_type_id', '=', room_type_id.id),
|
||||
], limit=1)
|
||||
if not avail_id:
|
||||
vals.update({
|
||||
'date': avail['date'],
|
||||
'virtual_room_id': vroom_id.id,
|
||||
'room_type_id': room_type_id.id,
|
||||
})
|
||||
avail_id = vroom_avail_obj.with_context({
|
||||
avail_id = room_type_avail_obj.with_context({
|
||||
'mail_create_nosubscribe': True,
|
||||
}).create(vals)
|
||||
else:
|
||||
@@ -140,16 +140,16 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
@api.model
|
||||
def _hcalendar_pricelist_json_data(self, prices):
|
||||
json_data = {}
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
for rec in prices:
|
||||
virtual_room_id = vroom_obj.search([
|
||||
room_type_id = room_type_obj.search([
|
||||
('product_id.product_tmpl_id', '=', rec.product_tmpl_id.id)
|
||||
], limit=1)
|
||||
if not virtual_room_id:
|
||||
if not room_type_id:
|
||||
continue
|
||||
|
||||
# TODO: date_end - date_start loop
|
||||
json_data.setdefault(virtual_room_id.id, []).append({
|
||||
json_data.setdefault(room_type_id.id, []).append({
|
||||
'id': rec.id,
|
||||
'price': rec.fixed_price,
|
||||
'date': rec.date_start,
|
||||
@@ -161,7 +161,7 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
json_data = {}
|
||||
for rec in restrictions:
|
||||
# TODO: date_end - date_start loop
|
||||
json_data.setdefault(rec.virtual_room_id.id, []).append({
|
||||
json_data.setdefault(rec.room_type_id.id, []).append({
|
||||
'id': rec.id,
|
||||
'date': rec.date_start,
|
||||
'min_stay': rec.min_stay,
|
||||
@@ -178,30 +178,30 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
def _hcalendar_availability_json_data(self, dfrom, dto):
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False)
|
||||
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
|
||||
vrooms = self.env['hotel.room.type'].search([])
|
||||
room_types = self.env['hotel.room.type'].search([])
|
||||
json_data = {}
|
||||
|
||||
for vroom in vrooms:
|
||||
json_data[vroom.id] = []
|
||||
for room_type in room_types:
|
||||
json_data[room_type.id] = []
|
||||
for i in range(0, date_diff):
|
||||
cur_date = date_start + timedelta(days=i)
|
||||
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
avail = self.env['hotel.room.type.availability'].search([
|
||||
('date', '=', cur_date_str),
|
||||
('virtual_room_id', '=', vroom.id)
|
||||
('room_type_id', '=', room_type.id)
|
||||
])
|
||||
if avail:
|
||||
json_data[vroom.id].append({
|
||||
json_data[room_type.id].append({
|
||||
'id': avail.id,
|
||||
'date': avail.date,
|
||||
'avail': avail.avail,
|
||||
'no_ota': avail.no_ota,
|
||||
})
|
||||
else:
|
||||
json_data[vroom.id].append({
|
||||
json_data[room_type.id].append({
|
||||
'id': False,
|
||||
'date': cur_date_str,
|
||||
'avail': vroom.max_real_rooms,
|
||||
'avail': room_type.max_real_rooms,
|
||||
'no_ota': False,
|
||||
})
|
||||
return json_data
|
||||
@@ -239,25 +239,24 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _hcalendar_get_count_reservations_json_data(self, dfrom, dto):
|
||||
vrooms = self.env['hotel.room.type'].search([])
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False)
|
||||
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
|
||||
hotel_vroom_obj = self.env['hotel.room.type']
|
||||
vrooms = hotel_vroom_obj.search([])
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
room_types = room_type_obj.search([])
|
||||
json_data = {}
|
||||
|
||||
for vroom in vrooms:
|
||||
for room_type in room_types:
|
||||
for i in range(0, date_diff):
|
||||
cur_date = date_start + timedelta(days=i)
|
||||
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
json_data.setdefault(vroom.id, []).append({
|
||||
json_data.setdefault(room_type.id, []).append({
|
||||
'date': cur_date_str,
|
||||
'num': len(
|
||||
hotel_vroom_obj.check_availability_virtual_room(
|
||||
room_type_obj.check_availability_room(
|
||||
cur_date_str,
|
||||
cur_date_str,
|
||||
virtual_room_id=vroom.id)),
|
||||
room_type_id=room_type.id)),
|
||||
})
|
||||
|
||||
return json_data
|
||||
@@ -280,11 +279,11 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
restriction_id = int(restriction_id)
|
||||
vals.update({'restriction_id': restriction_id})
|
||||
|
||||
vroom_rest_it_obj = self.env['hotel.room.type.restriction.item']
|
||||
restriction_item_ids = vroom_rest_it_obj.search([
|
||||
room_type_rest_it_obj = self.env['hotel.room.type.restriction.item']
|
||||
restriction_item_ids = room_type_rest_it_obj.search([
|
||||
('date_start', '>=', dfrom), ('date_end', '<=', dto),
|
||||
('restriction_id', '=', restriction_id),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
])
|
||||
|
||||
pricelist_item_ids = self.env['product.pricelist.item'].search([
|
||||
|
||||
@@ -64,7 +64,6 @@ class HotelReservation(models.Model):
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
json_rooms = []
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
for room in rooms:
|
||||
json_rooms.append((
|
||||
room.id,
|
||||
@@ -168,20 +167,20 @@ class HotelReservation(models.Model):
|
||||
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
|
||||
# Get Prices
|
||||
json_rooms_rests = {}
|
||||
room_type_ids = self.env['hotel.room.type'].search(
|
||||
room_types = self.env['hotel.room.type'].search(
|
||||
[],
|
||||
order='hcal_sequence ASC')
|
||||
vroom_rest_obj = self.env['hotel.room.type.restriction.item']
|
||||
for room_type_id in room_type_ids:
|
||||
room_type_rest_obj = self.env['hotel.room.type.restriction.item']
|
||||
for room_type in room_types:
|
||||
days = {}
|
||||
for i in range(0, date_diff):
|
||||
ndate = date_start + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
rest_id = vroom_rest_obj.search([
|
||||
('room_type_id', '=', room_type_id.id),
|
||||
rest_id = room_type_rest_obj.search([
|
||||
('room_type_id', '=', room_type.id),
|
||||
('date_start', '>=', ndate_str),
|
||||
('date_end', '<=', ndate_str),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('restriction_id', '=', restriction_id)
|
||||
], limit=1)
|
||||
if rest_id and (rest_id.min_stay or rest_id.min_stay_arrival or
|
||||
@@ -198,7 +197,7 @@ class HotelReservation(models.Model):
|
||||
rest_id.closed_arrival,
|
||||
rest_id.closed_departure)
|
||||
})
|
||||
json_rooms_rests.update({room_type_id.id: days})
|
||||
json_rooms_rests.update({room_type.id: days})
|
||||
return json_rooms_rests
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class HotelVirtualRoomAvailability(models.Model):
|
||||
class HotelRoomTypeAvailability(models.Model):
|
||||
_inherit = 'hotel.room.type.availability'
|
||||
|
||||
@api.model
|
||||
@@ -13,7 +13,7 @@ class HotelVirtualRoomAvailability(models.Model):
|
||||
'date': res.date,
|
||||
'avail': res.avail,
|
||||
'no_ota': res.no_ota,
|
||||
'virtual_room_id': res.virtual_room_id.id,
|
||||
'room_type_id': res.room_type_id.id,
|
||||
'id': res.id,
|
||||
})
|
||||
return res
|
||||
@@ -27,7 +27,7 @@ class HotelVirtualRoomAvailability(models.Model):
|
||||
'date': record.date,
|
||||
'avail': record.avail,
|
||||
'no_ota': record.no_ota,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'room_type_id': record.room_type_id.id,
|
||||
'id': record.id,
|
||||
})
|
||||
return ret_vals
|
||||
@@ -39,8 +39,8 @@ class HotelVirtualRoomAvailability(models.Model):
|
||||
for record in self:
|
||||
unlink_vals.append({
|
||||
'date': record.date,
|
||||
'avail': record.virtual_room_id.max_real_rooms,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'avail': record.room_type_id.max_real_rooms,
|
||||
'room_type_id': record.room_type_id.id,
|
||||
'no_ota': False,
|
||||
'id': record.id,
|
||||
})
|
||||
@@ -5,7 +5,7 @@ from odoo import models, fields, api
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
class HotelRoomTypeResrtrictionItem(models.Model):
|
||||
_inherit = 'hotel.room.type.restriction.item'
|
||||
|
||||
@api.model
|
||||
@@ -17,7 +17,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
restriction_id = res.restriction_id.id
|
||||
if restriction_id == restrictions_parity_id and \
|
||||
self.applied_on == '0_virtual_room':
|
||||
self.applied_on == '0_room_type':
|
||||
self.env['bus.hotel.calendar'].send_restriction_notification({
|
||||
'restriction_id': self.restriction_id.id,
|
||||
'date': self.date_start,
|
||||
@@ -28,7 +28,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
'closed': self.closed,
|
||||
'closed_departure': self.closed_departure,
|
||||
'closed_arrival': self.closed_arrival,
|
||||
'virtual_room_id': self.virtual_room_id.id,
|
||||
'room_type_id': self.room_type_id.id,
|
||||
'id': self.id,
|
||||
})
|
||||
return res
|
||||
@@ -44,7 +44,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for record in self:
|
||||
if record.restriction_id.id != restrictions_parity_id or \
|
||||
record.applied_on != '0_virtual_room':
|
||||
record.applied_on != '0_room_type':
|
||||
continue
|
||||
bus_hotel_calendar_obj.send_restriction_notification({
|
||||
'restriction_id': record.restriction_id.id,
|
||||
@@ -56,7 +56,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
'closed': record.closed,
|
||||
'closed_departure': record.closed_departure,
|
||||
'closed_arrival': record.closed_arrival,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'room_type_id': record.room_type_id.id,
|
||||
'id': record.id,
|
||||
})
|
||||
return ret_vals
|
||||
@@ -71,7 +71,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
unlink_vals = []
|
||||
for record in self:
|
||||
if record.restriction_id.id != restrictions_parity_id or \
|
||||
record.applied_on != '0_virtual_room':
|
||||
record.applied_on != '0_room_type':
|
||||
continue
|
||||
unlink_vals.append({
|
||||
'restriction_id': record.restriction_id.id,
|
||||
@@ -83,7 +83,7 @@ class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
'closed': False,
|
||||
'closed_departure': False,
|
||||
'closed_arrival': False,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'room_type_id': record.room_type_id.id,
|
||||
'id': record.id,
|
||||
})
|
||||
res = super(HotelVirtualRoomResrtrictionItem, self).unlink()
|
||||
@@ -18,19 +18,19 @@ class IrDefault(models.Model):
|
||||
pricelist_items = self.env['product.pricelist.item'].search([
|
||||
('pricelist_id', '=', pricelist_id)
|
||||
])
|
||||
vroom_obj = self.env['hotel.room.type']
|
||||
vroom_pr_cached_obj = self.env['room.pricelist.cached']
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
room_pr_cached_obj = self.env['room.pricelist.cached']
|
||||
for pitem in pricelist_items:
|
||||
date_start = pitem.date_start
|
||||
product_tmpl_id = pitem.product_tmpl_id.id
|
||||
fixed_price = pitem.fixed_price
|
||||
vroom = vroom_obj.search([
|
||||
room_type = room_type_obj.search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id),
|
||||
('date_start', '>=', date_utils.now().strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
], limit=1)
|
||||
vroom_pr_cached_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
room_pr_cached_obj.create({
|
||||
'room_type_id': room_type.id,
|
||||
'date': date_start,
|
||||
'price': fixed_price,
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ class ProductPricelistItem(models.Model):
|
||||
room_type = self.env['hotel.room.type'].search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id)
|
||||
], limit=1)
|
||||
if pricelist_id == pricelist_parity_id and vroom:
|
||||
if pricelist_id == pricelist_parity_id and room_type:
|
||||
prod = room_type.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
@@ -88,12 +88,12 @@ class ProductPricelistItem(models.Model):
|
||||
'id': record.id,
|
||||
})
|
||||
|
||||
vroom_pr_cached_id = room_pr_cached_obj.search([
|
||||
room_pr_cached_id = room_pr_cached_obj.search([
|
||||
('room_id', '=', room_type.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.write({'price': prod_price})
|
||||
if room_pr_cached_id:
|
||||
room_pr_cached_id.write({'price': prod_price})
|
||||
else:
|
||||
room_pr_cached_obj.create({
|
||||
'room_id': room_type.id,
|
||||
|
||||
@@ -60,7 +60,7 @@ return AbstractModel.extend({
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type',
|
||||
method: 'search_read',
|
||||
args: [false, ['cat_id','name']],
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -71,7 +71,7 @@ var MPMSCalendarController = AbstractController.extend({
|
||||
self.renderer._days_tooltips = results['events'];
|
||||
var rooms = [];
|
||||
for (var r of results['rooms']) {
|
||||
var nroom = new HVRoom(
|
||||
var nroom = new HRoomType(
|
||||
r[0], // Id
|
||||
r[1], // Name
|
||||
r[2], // Capacity
|
||||
@@ -112,15 +112,15 @@ var MPMSCalendarController = AbstractController.extend({
|
||||
switch (notif[1]['type']) {
|
||||
case 'availability':
|
||||
var avail = notif[1]['availability'];
|
||||
var vroom = Object.keys(avail)[0];
|
||||
var day = Object.keys(avail[vroom])[0];
|
||||
var room_type = Object.keys(avail)[0];
|
||||
var day = Object.keys(avail[room_type])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var availability = {};
|
||||
availability[vroom] = [{
|
||||
availability[room_type] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'avail': avail[vroom][day][0],
|
||||
'no_ota': avail[vroom][day][1],
|
||||
'id': avail[vroom][day][2]
|
||||
'avail': avail[room_type][day][0],
|
||||
'no_ota': avail[room_type][day][1],
|
||||
'id': avail[room_type][day][2]
|
||||
}];
|
||||
this.renderer._hcalendar.addAvailability(availability);
|
||||
break;
|
||||
@@ -143,22 +143,22 @@ var MPMSCalendarController = AbstractController.extend({
|
||||
this.renderer._hcalendar.addPricelist(pr);
|
||||
break;
|
||||
case 'restriction':
|
||||
// FIXME: Expected one day and one vroom
|
||||
// FIXME: Expected one day and one room_type
|
||||
var restriction = notif[1]['restriction'];
|
||||
var vroom = Object.keys(restriction)[0];
|
||||
var day = Object.keys(restriction[vroom])[0];
|
||||
var room_type = Object.keys(restriction)[0];
|
||||
var day = Object.keys(restriction[room_type])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var rest = {};
|
||||
rest[vroom] = [{
|
||||
rest[room_type] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'min_stay': restriction[vroom][day][0],
|
||||
'min_stay_arrival': restriction[vroom][day][1],
|
||||
'max_stay': restriction[vroom][day][2],
|
||||
'max_stay_arrival': restriction[vroom][day][3],
|
||||
'closed': restriction[vroom][day][4],
|
||||
'closed_arrival': restriction[vroom][day][5],
|
||||
'closed_departure': restriction[vroom][day][6],
|
||||
'id': restriction[vroom][day][7]
|
||||
'min_stay': restriction[room_type][day][0],
|
||||
'min_stay_arrival': restriction[room_type][day][1],
|
||||
'max_stay': restriction[room_type][day][2],
|
||||
'max_stay_arrival': restriction[room_type][day][3],
|
||||
'closed': restriction[room_type][day][4],
|
||||
'closed_arrival': restriction[room_type][day][5],
|
||||
'closed_departure': restriction[room_type][day][6],
|
||||
'id': restriction[room_type][day][7]
|
||||
}];
|
||||
this.renderer._hcalendar.addRestrictions(rest);
|
||||
break;
|
||||
|
||||
@@ -132,7 +132,7 @@ var HotelCalendarManagementView = AbstractRenderer.extend({
|
||||
this._hcalendar = new HotelCalendarManagement('#hcal_management_widget', options, this.$el[0]);
|
||||
this._assignHCalendarEvents();
|
||||
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
|
||||
|
||||
// Sticky Header Days
|
||||
this.$ehcal.scroll(this._on_scroll.bind(this));
|
||||
@@ -409,7 +409,7 @@ var HotelCalendarManagementView = AbstractRenderer.extend({
|
||||
self._assign_extra_info();
|
||||
});
|
||||
this._last_dates = params['dates'];
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
|
||||
this._on_scroll(); // FIXME: Workaround for update sticky header
|
||||
},
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ var HotelCalendarManagementView = View.extend({
|
||||
}
|
||||
});
|
||||
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
|
||||
|
||||
// Sticky Header Days
|
||||
this.$ehcal.scroll(this._on_scroll.bind(this));
|
||||
@@ -204,7 +204,7 @@ var HotelCalendarManagementView = View.extend({
|
||||
self._days_tooltips = results['events'];
|
||||
var rooms = [];
|
||||
for (var r of results['rooms']) {
|
||||
var nroom = new HVRoom(
|
||||
var nroom = new HRoomType(
|
||||
r[0], // Id
|
||||
r[1], // Name
|
||||
r[2], // Capacity
|
||||
@@ -478,15 +478,15 @@ var HotelCalendarManagementView = View.extend({
|
||||
switch (notif[1]['type']) {
|
||||
case 'availability':
|
||||
var avail = notif[1]['availability'];
|
||||
var vroom = Object.keys(avail)[0];
|
||||
var day = Object.keys(avail[vroom])[0];
|
||||
var room_type = Object.keys(avail)[0];
|
||||
var day = Object.keys(avail[room_type])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var availability = {};
|
||||
availability[vroom] = [{
|
||||
availability[room_type] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'avail': avail[vroom][day][0],
|
||||
'no_ota': avail[vroom][day][1],
|
||||
'id': avail[vroom][day][2]
|
||||
'avail': avail[room_type][day][0],
|
||||
'no_ota': avail[room_type][day][1],
|
||||
'id': avail[room_type][day][2]
|
||||
}];
|
||||
this._hcalendar.addAvailability(availability);
|
||||
break;
|
||||
@@ -509,22 +509,22 @@ var HotelCalendarManagementView = View.extend({
|
||||
this._hcalendar.addPricelist(pr);
|
||||
break;
|
||||
case 'restriction':
|
||||
// FIXME: Expected one day and one vroom
|
||||
// FIXME: Expected one day and one room_type
|
||||
var restriction = notif[1]['restriction'];
|
||||
var vroom = Object.keys(restriction)[0];
|
||||
var day = Object.keys(restriction[vroom])[0];
|
||||
var room_type = Object.keys(restriction)[0];
|
||||
var day = Object.keys(restriction[room_type])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var rest = {};
|
||||
rest[vroom] = [{
|
||||
rest[room_type] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'min_stay': restriction[vroom][day][0],
|
||||
'min_stay_arrival': restriction[vroom][day][1],
|
||||
'max_stay': restriction[vroom][day][2],
|
||||
'max_stay_arrival': restriction[vroom][day][3],
|
||||
'closed': restriction[vroom][day][4],
|
||||
'closed_arrival': restriction[vroom][day][5],
|
||||
'closed_departure': restriction[vroom][day][6],
|
||||
'id': restriction[vroom][day][7]
|
||||
'min_stay': restriction[room_type][day][0],
|
||||
'min_stay_arrival': restriction[room_type][day][1],
|
||||
'max_stay': restriction[room_type][day][2],
|
||||
'max_stay_arrival': restriction[room_type][day][3],
|
||||
'closed': restriction[room_type][day][4],
|
||||
'closed_arrival': restriction[room_type][day][5],
|
||||
'closed_departure': restriction[room_type][day][6],
|
||||
'id': restriction[room_type][day][7]
|
||||
}];
|
||||
this._hcalendar.addRestrictions(rest);
|
||||
break;
|
||||
@@ -543,7 +543,7 @@ var HotelCalendarManagementView = View.extend({
|
||||
self._assign_extra_info();
|
||||
});
|
||||
this._last_dates = params['dates'];
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-room_type-data-header");
|
||||
this._on_scroll(); // FIXME: Workaround for update sticky header
|
||||
},
|
||||
|
||||
|
||||
@@ -690,8 +690,8 @@ HotelCalendar.prototype = {
|
||||
},
|
||||
|
||||
addRestrictions: function(/*Object*/restrictions) {
|
||||
var vroom_ids = Object.keys(restrictions);
|
||||
for (var vid of vroom_ids) {
|
||||
var room_type_ids = Object.keys(restrictions);
|
||||
for (var vid of room_type_ids) {
|
||||
if (vid in this._restrictions) {
|
||||
this._restrictions[vid] = _.extend(this._restrictions[vid], restrictions[vid]);
|
||||
}
|
||||
@@ -1276,7 +1276,7 @@ HotelCalendar.prototype = {
|
||||
row = tbody.insertRow();
|
||||
row.setAttribute('id', this._sanitizeId(`ROW_DETAIL_PRICE_ROOM_${key}_${listitem.room}`));
|
||||
row.dataset.hcalPricelist = key;
|
||||
row.dataset.hcalVRoomId = listitem.room
|
||||
row.dataset.hcalRoomTypeId = listitem.room
|
||||
row.classList.add('hcal-row-detail-room-price-group-item');
|
||||
cell = row.insertCell();
|
||||
var span = document.createElement('span');
|
||||
@@ -1306,7 +1306,7 @@ HotelCalendar.prototype = {
|
||||
input.setAttribute('id', this._sanitizeId(`INPUT_PRICE_${key}_${listitem.room}_${dd_local.format(HotelCalendar.DATE_FORMAT_SHORT_)}`));
|
||||
input.setAttribute('type', 'edit');
|
||||
input.setAttribute('title', 'Price');
|
||||
input.setAttribute('name', 'vroom_price_day');
|
||||
input.setAttribute('name', 'room_type_price_day');
|
||||
input.dataset.hcalParentCell = cell.getAttribute('id');
|
||||
var dd_fmrt = dd_local.format(HotelCalendar.DATE_FORMAT_SHORT_);
|
||||
input.dataset.orgValue = input.value = _.has(listitem['days'], dd_fmrt)?Number(listitem['days'][dd_fmrt]).toLocaleString():'...';
|
||||
@@ -1335,8 +1335,8 @@ HotelCalendar.prototype = {
|
||||
var orgValue = input.dataset.orgValue;
|
||||
var parentCell = this.edtable.querySelector(`#${input.dataset.hcalParentCell}`);
|
||||
var parentRow = this.edtable.querySelector(`#${parentCell.dataset.hcalParentRow}`);
|
||||
if (!(parentRow.dataset.hcalVRoomId in data)) { data[parentRow.dataset.hcalVRoomId] = []; }
|
||||
data[parentRow.dataset.hcalVRoomId].push({
|
||||
if (!(parentRow.dataset.hcalRoomTypeId in data)) { data[parentRow.dataset.hcalRoomTypeId] = []; }
|
||||
data[parentRow.dataset.hcalRoomTypeId].push({
|
||||
'date': HotelCalendar.toMoment(parentCell.dataset.hcalDate).format('YYYY-MM-DD'),
|
||||
'price': value
|
||||
});
|
||||
@@ -2107,13 +2107,13 @@ HotelCalendar.prototype = {
|
||||
this._updatePriceList();
|
||||
},
|
||||
|
||||
updateVRoomPrice: function(pricelist_id, vroom_id, date, price) {
|
||||
updateRoomTypePrice: function(pricelist_id, room_type_id, date, price) {
|
||||
var strDate = date.format(HotelCalendar.DATE_FORMAT_SHORT_);
|
||||
var cellId = this._sanitizeId(`CELL_PRICE_${pricelist_id}_${vroom_id}_${strDate}`);
|
||||
var cellId = this._sanitizeId(`CELL_PRICE_${pricelist_id}_${room_type_id}_${strDate}`);
|
||||
var input = this.edtable.querySelector(`#${cellId} input`);
|
||||
if (input) {
|
||||
input.dataset.orgValue = input.value = price;
|
||||
var pr_fk = _.findKey(this._pricelist[pricelist_id], {'room': vroom_id});
|
||||
var pr_fk = _.findKey(this._pricelist[pricelist_id], {'room': room_type_id});
|
||||
this._pricelist[pricelist_id][pr_fk].days[strDate] = price;
|
||||
}
|
||||
},
|
||||
@@ -2289,7 +2289,7 @@ HotelCalendar.prototype = {
|
||||
var orgValue = elm.dataset.orgValue;
|
||||
var name = elm.getAttribute('name');
|
||||
|
||||
if (name === 'vroom_price_day') {
|
||||
if (name === 'room_type_price_day') {
|
||||
if (!this._isNumeric(value)) {
|
||||
elm.style.backgroundColor = 'red';
|
||||
} else if (orgValue !== value) {
|
||||
@@ -2306,13 +2306,13 @@ HotelCalendar.prototype = {
|
||||
var parentCell = this.edtable.querySelector(`#${elm.dataset.hcalParentCell}`);
|
||||
var parentRow = this.edtable.querySelector(`#${parentCell.dataset.hcalParentRow}`);
|
||||
var vals = {
|
||||
'vroom_id': +parentRow.dataset.hcalVRoomId,
|
||||
'room_type_id': +parentRow.dataset.hcalRoomTypeId,
|
||||
'date': HotelCalendar.toMoment(parentCell.dataset.hcalDate),
|
||||
'price': value,
|
||||
'old_price': orgValue,
|
||||
'pricelist_id': +parentRow.dataset.hcalPricelist
|
||||
};
|
||||
//this.updateVRoomPrice(vals['pricelist_id'], vals['vroom_id'], vals['date'], vals['price']);
|
||||
//this.updateRoomTypePrice(vals['pricelist_id'], vals['room_type_id'], vals['date'], vals['price']);
|
||||
this._dispatchEvent('hcalOnPricelistChanged', vals);
|
||||
|
||||
if (this.edivc.querySelector('.hcal-input-changed') !== null)
|
||||
|
||||
@@ -74,7 +74,7 @@ function HotelCalendarManagement(/*String*/querySelector, /*Dictionary*/options,
|
||||
};
|
||||
|
||||
// Check correct values
|
||||
if (this.options.rooms.length > 0 && !(this.options.rooms[0] instanceof HVRoom)) {
|
||||
if (this.options.rooms.length > 0 && !(this.options.rooms[0] instanceof HRoomType)) {
|
||||
this.options.rooms = [];
|
||||
console.warn("[Hotel Calendar Management][init] Invalid Room definiton!");
|
||||
}
|
||||
@@ -397,9 +397,9 @@ HotelCalendarManagement.prototype = {
|
||||
this.e.removeChild(this.e.lastChild);
|
||||
}
|
||||
|
||||
// VRoom Names
|
||||
// RoomType Names
|
||||
this.edivrhl = document.createElement("div");
|
||||
this.edivrhl.classList.add('table-vrooms');
|
||||
this.edivrhl.classList.add('table-room_types');
|
||||
this.e.appendChild(this.edivrhl);
|
||||
this.etableRooms = document.createElement("table");
|
||||
this.etableRooms.classList.add('hcal-management-table');
|
||||
@@ -412,7 +412,7 @@ HotelCalendarManagement.prototype = {
|
||||
this.e.appendChild(this.edivm);
|
||||
// Days
|
||||
this.edivrh = document.createElement("div");
|
||||
this.edivrh.classList.add('table-vroom-data-header');
|
||||
this.edivrh.classList.add('table-room_type-data-header');
|
||||
this.edivm.appendChild(this.edivrh);
|
||||
this.etableHeader = document.createElement("table");
|
||||
this.etableHeader.classList.add('hcal-management-table');
|
||||
@@ -420,7 +420,7 @@ HotelCalendarManagement.prototype = {
|
||||
this.edivrh.appendChild(this.etableHeader);
|
||||
// Data
|
||||
this.edivr = document.createElement("div");
|
||||
this.edivr.classList.add('table-vroom-data');
|
||||
this.edivr.classList.add('table-room_type-data');
|
||||
this.edivm.appendChild(this.edivr);
|
||||
this.etable = document.createElement("table");
|
||||
this.etable.classList.add('hcal-management-table');
|
||||
@@ -503,8 +503,8 @@ HotelCalendarManagement.prototype = {
|
||||
|
||||
//==== PRICELIST
|
||||
addPricelist: function(/*Object*/pricelist) {
|
||||
var vroom_ids = Object.keys(pricelist);
|
||||
for (var vid of vroom_ids) {
|
||||
var room_type_ids = Object.keys(pricelist);
|
||||
for (var vid of room_type_ids) {
|
||||
if (vid in this._pricelist) {
|
||||
for (var price of pricelist[vid]) {
|
||||
var index = _.findIndex(this._pricelist[vid], {date: price['date']});
|
||||
@@ -524,10 +524,10 @@ HotelCalendarManagement.prototype = {
|
||||
|
||||
_updatePriceList: function() {
|
||||
var keys = Object.keys(this._pricelist);
|
||||
for (var vroomId of keys) {
|
||||
for (var price of this._pricelist[vroomId]) {
|
||||
for (var room_typeId of keys) {
|
||||
for (var price of this._pricelist[room_typeId]) {
|
||||
var dd = HotelCalendarManagement.toMoment(price.date, this.options.dateFormatShort);
|
||||
var inputId = this._sanitizeId(`PRICE_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`);
|
||||
var inputId = this._sanitizeId(`PRICE_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`);
|
||||
var input = this.etable.querySelector(`#${inputId}`);
|
||||
if (input && !input.classList.contains('hcal-management-input-changed')) {
|
||||
input.dataset.orgValue = price.price;
|
||||
@@ -559,8 +559,8 @@ HotelCalendarManagement.prototype = {
|
||||
|
||||
//==== RESTRICTIONS
|
||||
addRestrictions: function(/*Object*/restrictions) {
|
||||
var vroom_ids = Object.keys(restrictions);
|
||||
for (var vid of vroom_ids) {
|
||||
var room_type_ids = Object.keys(restrictions);
|
||||
for (var vid of room_type_ids) {
|
||||
if (vid in this._restrictions) {
|
||||
for (var rest of restrictions[vid]) {
|
||||
var index = _.findIndex(this._restrictions[vid], {date: rest['date']});
|
||||
@@ -580,15 +580,15 @@ HotelCalendarManagement.prototype = {
|
||||
|
||||
_updateRestrictions: function() {
|
||||
var keys = Object.keys(this._restrictions);
|
||||
for (var vroomId of keys) {
|
||||
var room = this.getRoom(vroomId);
|
||||
for (var restriction of this._restrictions[vroomId]) {
|
||||
for (var room_typeId of keys) {
|
||||
var room = this.getRoom(room_typeId);
|
||||
for (var restriction of this._restrictions[room_typeId]) {
|
||||
var dd = HotelCalendarManagement.toMoment(restriction.date, this.options.dateFormatShort);
|
||||
var inputIds = [
|
||||
this._sanitizeId(`MIN_STAY_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay,
|
||||
this._sanitizeId(`MIN_STAY_ARRIVAL_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay_arrival,
|
||||
this._sanitizeId(`MAX_STAY_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay,
|
||||
this._sanitizeId(`MAX_STAY_ARRIVAL_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay_arrival,
|
||||
this._sanitizeId(`MIN_STAY_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay,
|
||||
this._sanitizeId(`MIN_STAY_ARRIVAL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.min_stay_arrival,
|
||||
this._sanitizeId(`MAX_STAY_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay,
|
||||
this._sanitizeId(`MAX_STAY_ARRIVAL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`), restriction.max_stay_arrival,
|
||||
];
|
||||
for (var i=0; i<inputIds.length; i+=2) {
|
||||
var inputItem = this.etable.querySelector(`#${inputIds[i]}`);
|
||||
@@ -598,7 +598,7 @@ HotelCalendarManagement.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
var inputClousureId = this._sanitizeId(`CLOUSURE_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`);
|
||||
var inputClousureId = this._sanitizeId(`CLOUSURE_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`);
|
||||
var inputClousure = this.etable.querySelector(`#${inputClousureId}`);
|
||||
if (inputClousure && !inputClousure.classList.contains('hcal-management-input-changed')) {
|
||||
inputClousure.dataset.orgValue = inputClousure.value = (restriction.closed && 'closed') ||
|
||||
@@ -651,11 +651,11 @@ HotelCalendarManagement.prototype = {
|
||||
//==== FREE Rooms
|
||||
_updateNumFreeRooms: function() {
|
||||
var keys = Object.keys(this._free_rooms);
|
||||
for (var vroomId of keys) {
|
||||
for (var fnroom of this._free_rooms[vroomId]) {
|
||||
for (var room_typeId of keys) {
|
||||
for (var fnroom of this._free_rooms[room_typeId]) {
|
||||
var dd = HotelCalendarManagement.toMoment(fnroom.date, this.options.dateFormatShort);
|
||||
var inputIds = [
|
||||
`FREE_ROOMS_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, fnroom.num,
|
||||
`FREE_ROOMS_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, fnroom.num,
|
||||
];
|
||||
|
||||
for (var i=0; i<inputIds.length; i+=2) {
|
||||
@@ -671,8 +671,8 @@ HotelCalendarManagement.prototype = {
|
||||
|
||||
//==== AVAILABILITY
|
||||
addAvailability: function(/*Object*/availability) {
|
||||
var vroom_ids = Object.keys(availability);
|
||||
for (var vid of vroom_ids) {
|
||||
var room_type_ids = Object.keys(availability);
|
||||
for (var vid of room_type_ids) {
|
||||
if (vid in this._availability) {
|
||||
for (var avail of availability[vid]) {
|
||||
var index = _.findIndex(this._availability[vid], {date: avail['date']});
|
||||
@@ -692,12 +692,12 @@ HotelCalendarManagement.prototype = {
|
||||
|
||||
_updateAvailability: function() {
|
||||
var keys = Object.keys(this._availability);
|
||||
for (var vroomId of keys) {
|
||||
for (var avail of this._availability[vroomId]) {
|
||||
for (var room_typeId of keys) {
|
||||
for (var avail of this._availability[room_typeId]) {
|
||||
var dd = HotelCalendarManagement.toMoment(avail.date, this.options.dateFormatShort);
|
||||
var inputIds = [
|
||||
`AVAIL_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.avail,
|
||||
`NO_OTA_${vroomId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.no_ota
|
||||
`AVAIL_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.avail,
|
||||
`NO_OTA_${room_typeId}_${dd.format(HotelCalendarManagement._DATE_FORMAT_SHORT)}`, avail.no_ota
|
||||
];
|
||||
|
||||
for (var i=0; i<inputIds.length; i+=2) {
|
||||
@@ -1062,7 +1062,7 @@ HotelCalendarManagement.toMoment = function(/*String,MomentObject*/ndate, /*Stri
|
||||
|
||||
|
||||
/** ROOM OBJECT **/
|
||||
function HVRoom(/*Int*/id, /*String*/name, /*Int*/capacity, /*Float*/price) {
|
||||
function HRoomType(/*Int*/id, /*String*/name, /*Int*/capacity, /*Float*/price) {
|
||||
this.id = id || -1;
|
||||
this.name = name;
|
||||
this.capacity = capacity;
|
||||
@@ -1070,7 +1070,7 @@ function HVRoom(/*Int*/id, /*String*/name, /*Int*/capacity, /*Float*/price) {
|
||||
|
||||
this.userData_ = {};
|
||||
}
|
||||
HVRoom.prototype = {
|
||||
HRoomType.prototype = {
|
||||
clearUserData: function() { this.userData_ = {}; },
|
||||
getUserData: function(/*String?*/key) {
|
||||
if (typeof key === 'undefined') {
|
||||
@@ -1080,7 +1080,7 @@ HVRoom.prototype = {
|
||||
},
|
||||
addUserData: function(/*Dictionary*/data) {
|
||||
if (!_.isObject(data)) {
|
||||
console.warn("[Hotel Calendar Management][HVRoom][setUserData] Invalid Data! Need be a object!");
|
||||
console.warn("[Hotel Calendar Management][HRoomType][setUserData] Invalid Data! Need be a object!");
|
||||
} else {
|
||||
this.userData_ = _.extend(this.userData_, data);
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ class TestManagementCalendar(TestHotelCalendar):
|
||||
rest_it_obj = self.env['hotel.room.type.restriction.item'].sudo(
|
||||
self.user_hotel_manager)
|
||||
rest_ids = rest_it_obj.search([
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('restriction_id', '=', self.parity_restrictions_id),
|
||||
('virtual_room_id', 'in', (self.hotel_vroom_budget.id,
|
||||
('room_type_id', 'in', (self.hotel_vroom_budget.id,
|
||||
self.hotel_vroom_special.id)),
|
||||
])
|
||||
rest_ids.sudo(self.user_hotel_manager).unlink()
|
||||
@@ -160,7 +160,7 @@ class TestManagementCalendar(TestHotelCalendar):
|
||||
|
||||
# CHANGE AVAIL
|
||||
avail_ids = vroom_avail_obj.search([
|
||||
('virtual_room_id', 'in', (self.hotel_vroom_budget.id,
|
||||
('room_type_id', 'in', (self.hotel_vroom_budget.id,
|
||||
self.hotel_vroom_special.id)),
|
||||
])
|
||||
for avail_id in avail_ids:
|
||||
@@ -183,7 +183,7 @@ class TestManagementCalendar(TestHotelCalendar):
|
||||
|
||||
# REMOVE AVAIL
|
||||
avail_ids = vroom_avail_obj.search([
|
||||
('virtual_room_id', 'in', (self.hotel_vroom_budget.id,
|
||||
('room_type_id', 'in', (self.hotel_vroom_budget.id,
|
||||
self.hotel_vroom_special.id)),
|
||||
])
|
||||
avail_ids.sudo(self.user_hotel_manager).unlink()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="virtual_room_view_form" model="ir.ui.view">
|
||||
<record id="room_type_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_room_type_form" />
|
||||
<field name="arch" type="xml">
|
||||
|
||||
@@ -1,33 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import pytz
|
||||
# Copyright 2018 Dario Lodeiros
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import time
|
||||
import logging
|
||||
from decimal import Decimal
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import datetime, timedelta, date
|
||||
from openerp.exceptions import except_orm, UserError, ValidationError
|
||||
from datetime import timedelta
|
||||
from openerp.exceptions import ValidationError
|
||||
from openerp.tools import (
|
||||
misc,
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from openerp import models, fields, api, _
|
||||
@@ -48,7 +26,7 @@ class FolioWizard(models.TransientModel):
|
||||
def _get_default_checkin(self):
|
||||
folio = False
|
||||
default_arrival_hour = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_arrival_hour')
|
||||
'res.config.settings', 'default_arrival_hour')
|
||||
if 'folio_id' in self._context:
|
||||
folio = self.env['hotel.folio'].search([
|
||||
('id', '=', self._context['folio_id'])
|
||||
@@ -76,7 +54,7 @@ class FolioWizard(models.TransientModel):
|
||||
('id', '=', self._context['folio_id'])
|
||||
])
|
||||
if folio and folio.room_lines:
|
||||
return folio.room_lines[0].checkout
|
||||
return folio.room_lines[0].checkout
|
||||
else:
|
||||
tz_hotel = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'tz_hotel')
|
||||
@@ -103,8 +81,8 @@ class FolioWizard(models.TransientModel):
|
||||
'folio_wizard_id',
|
||||
string="Resevations")
|
||||
service_wizard_ids = fields.One2many('hotel.service.wizard',
|
||||
'folio_wizard_id',
|
||||
string='Services')
|
||||
'folio_wizard_id',
|
||||
string='Services')
|
||||
total = fields.Float('Total', compute='_computed_total')
|
||||
confirm = fields.Boolean('Confirm Reservations', default="1")
|
||||
autoassign = fields.Boolean('Autoassign', default="1")
|
||||
@@ -112,25 +90,25 @@ class FolioWizard(models.TransientModel):
|
||||
('door', 'Door'),
|
||||
('mail', 'Mail'),
|
||||
('phone', 'Phone')
|
||||
], string='Sales Channel', default=_get_default_channel_type)
|
||||
virtual_room_wizard_ids = fields.Many2many('hotel.virtual.room.wizard',
|
||||
string="Virtual Rooms")
|
||||
], string='Sales Channel', default=_get_default_channel_type)
|
||||
room_type_wizard_ids = fields.Many2many('hotel.room.type.wizard',
|
||||
string="Virtual Rooms")
|
||||
call_center = fields.Boolean(default=_get_default_center_user)
|
||||
|
||||
def assign_rooms(self):
|
||||
self.assign=True
|
||||
self.assign = True
|
||||
|
||||
@api.onchange('autoassign')
|
||||
def create_reservations(self):
|
||||
self.ensure_one()
|
||||
total = 0
|
||||
cmds = []
|
||||
for line in self.virtual_room_wizard_ids:
|
||||
for line in self.room_type_wizard_ids:
|
||||
if line.rooms_num == 0:
|
||||
continue
|
||||
if line.rooms_num > line.max_rooms:
|
||||
raise ValidationError(_("Too many rooms!"))
|
||||
elif line.virtual_room_id:
|
||||
raise ValidationError(_("Too many rooms!"))
|
||||
elif line.room_type_id:
|
||||
checkout_dt = date_utils.get_datetime(line.checkout)
|
||||
occupied = self.env['hotel.reservation'].occupied(
|
||||
line.checkin,
|
||||
@@ -138,15 +116,15 @@ class FolioWizard(models.TransientModel):
|
||||
rooms_occupied = occupied.mapped('product_id.id')
|
||||
free_rooms = self.env['hotel.room'].search([
|
||||
('product_id.id', 'not in', rooms_occupied),
|
||||
('price_virtual_room.id', '=', line.virtual_room_id.id)],
|
||||
order='sequence', limit=line.rooms_num)
|
||||
('price_room_type.id', '=', line.room_type_id.id)
|
||||
], order='sequence', limit=line.rooms_num)
|
||||
room_ids = free_rooms.mapped('product_id.id')
|
||||
product_list = self.env['product.product'].search([
|
||||
('id', 'in', room_ids)
|
||||
])
|
||||
nights = days_diff = date_utils.date_diff(line.checkin,
|
||||
line.checkout,
|
||||
hours=False)
|
||||
nights = date_utils.date_diff(line.checkin,
|
||||
line.checkout,
|
||||
hours=False)
|
||||
hotel_tz = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'hotel_tz')
|
||||
@@ -159,11 +137,10 @@ class FolioWizard(models.TransientModel):
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
res_price = 0
|
||||
res_partner = self.partner_id or self.env['res.partner'].browse('1')
|
||||
for i in range(0, nights):
|
||||
ndate = start_date_dt + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod = line.virtual_room_id.product_id.with_context(
|
||||
prod = line.room_type_id.product_id.with_context(
|
||||
lang=self.partner_id.lang,
|
||||
partner=self.partner_id.id,
|
||||
quantity=1,
|
||||
@@ -177,17 +154,17 @@ class FolioWizard(models.TransientModel):
|
||||
res_price = res_price - (res_price * line.discount)/100
|
||||
total += res_price
|
||||
cmds.append((0, False, {
|
||||
'checkin': line.checkin,
|
||||
'checkout': line.checkout,
|
||||
'discount': line.discount,
|
||||
'product_id': room.id,
|
||||
'nights': nights,
|
||||
'adults': adults,
|
||||
'children': 0,
|
||||
'virtual_room_id': line.virtual_room_id,
|
||||
'price': res_price,
|
||||
'amount_reservation': res_price
|
||||
}))
|
||||
'checkin': line.checkin,
|
||||
'checkout': line.checkout,
|
||||
'discount': line.discount,
|
||||
'product_id': room.id,
|
||||
'nights': nights,
|
||||
'adults': adults,
|
||||
'children': 0,
|
||||
'room_type_id': line.room_type_id,
|
||||
'price': res_price,
|
||||
'amount_reservation': res_price
|
||||
}))
|
||||
self.reservation_wizard_ids = cmds
|
||||
self.total = total
|
||||
|
||||
@@ -201,7 +178,6 @@ class FolioWizard(models.TransientModel):
|
||||
@param self: object pointer
|
||||
'''
|
||||
self.ensure_one()
|
||||
now_utc_dt = date_utils.now()
|
||||
if not self.checkin:
|
||||
self.checkin = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
if not self.checkout:
|
||||
@@ -217,36 +193,35 @@ class FolioWizard(models.TransientModel):
|
||||
dpt_hour = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_departure_hour')
|
||||
checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
checkout_str = "%s %s:00" % (checkout_str, dpt_hour)
|
||||
checkout_dt = date_utils.get_datetime(checkout_str, stz=tz)
|
||||
checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC')
|
||||
self.checkout = checkout_utc_dt.strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
self.checkout = checkout_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
checkout_dt = date_utils.get_datetime(self.checkout, stz=tz)
|
||||
# Reservation end day count as free day. Not check it
|
||||
checkout_dt -= timedelta(days=1)
|
||||
virtual_room_ids = self.env['hotel.room.type'].search([])
|
||||
virtual_rooms = []
|
||||
room_type_ids = self.env['hotel.room.type'].search([])
|
||||
room_types = []
|
||||
|
||||
for virtual in virtual_room_ids:
|
||||
virtual_rooms.append((0, False, {
|
||||
'virtual_room_id': virtual.id,
|
||||
'checkin': self.checkin,
|
||||
'checkout': self.checkout,
|
||||
'folio_wizard_id': self.id,
|
||||
}))
|
||||
self.virtual_room_wizard_ids = virtual_rooms
|
||||
for virtual in self.virtual_room_wizard_ids:
|
||||
virtual.update_price()
|
||||
for room_type in room_type_ids:
|
||||
room_types.append((0, False, {
|
||||
'room_type_id': room_type.id,
|
||||
'checkin': self.checkin,
|
||||
'checkout': self.checkout,
|
||||
'folio_wizard_id': self.id,
|
||||
}))
|
||||
self.room_type_wizard_ids = room_types
|
||||
for room_type in self.room_type_wizard_ids:
|
||||
room_type.update_price()
|
||||
|
||||
@api.depends('virtual_room_wizard_ids','reservation_wizard_ids','service_wizard_ids')
|
||||
@api.depends('room_type_wizard_ids','reservation_wizard_ids','service_wizard_ids')
|
||||
def _computed_total(self):
|
||||
total = 0
|
||||
for line in self.service_wizard_ids:
|
||||
total += line.price_total
|
||||
if not self.reservation_wizard_ids:
|
||||
for line in self.virtual_room_wizard_ids:
|
||||
for line in self.room_type_wizard_ids:
|
||||
total += line.total_price
|
||||
self.total = total
|
||||
else:
|
||||
@@ -258,36 +233,36 @@ class FolioWizard(models.TransientModel):
|
||||
def create_folio(self):
|
||||
self.ensure_one()
|
||||
if not self.partner_id:
|
||||
raise ValidationError(_("We need know the customer!"))
|
||||
raise ValidationError(_("We need know the customer!"))
|
||||
reservations = [(5, False, False)]
|
||||
services = [(5, False, False)]
|
||||
if self.autoassign == True:
|
||||
self.create_reservations()
|
||||
for line in self.reservation_wizard_ids:
|
||||
reservations.append((0, False, {
|
||||
'product_id': line.product_id.id,
|
||||
'adults': line.adults,
|
||||
'children': line.children,
|
||||
'checkin': line.checkin,
|
||||
'checkout': line.checkout,
|
||||
'discount': line.discount,
|
||||
'virtual_room_id': line.virtual_room_id.id,
|
||||
'to_read': line.to_read, #REFACT: wubook module
|
||||
'to_assign': line.to_assign,
|
||||
}))
|
||||
'product_id': line.product_id.id,
|
||||
'adults': line.adults,
|
||||
'children': line.children,
|
||||
'checkin': line.checkin,
|
||||
'checkout': line.checkout,
|
||||
'discount': line.discount,
|
||||
'room_type_id': line.room_type_id.id,
|
||||
'to_read': line.to_read, #REFACT: wubook module
|
||||
'to_assign': line.to_assign,
|
||||
}))
|
||||
for line in self.service_wizard_ids:
|
||||
services.append((0, False, {
|
||||
'product_id': line.product_id.id,
|
||||
'discount': line.discount,
|
||||
'price_unit': line.price_unit,
|
||||
'product_uom_qty': line.product_uom_qty,
|
||||
}))
|
||||
'product_id': line.product_id.id,
|
||||
'discount': line.discount,
|
||||
'price_unit': line.price_unit,
|
||||
'product_uom_qty': line.product_uom_qty,
|
||||
}))
|
||||
vals = {
|
||||
'partner_id': self.partner_id.id,
|
||||
'channel_type': self.channel_type,
|
||||
'room_lines': reservations,
|
||||
'service_lines': services,
|
||||
}
|
||||
'partner_id': self.partner_id.id,
|
||||
'channel_type': self.channel_type,
|
||||
'room_lines': reservations,
|
||||
'service_lines': services,
|
||||
}
|
||||
newfol = self.env['hotel.folio'].create(vals)
|
||||
for room in newfol.room_lines:
|
||||
room.on_change_checkin_checkout_product_id()
|
||||
@@ -302,8 +277,9 @@ class FolioWizard(models.TransientModel):
|
||||
action = {'type': 'ir.actions.act_window_close'}
|
||||
return action
|
||||
|
||||
class VirtualRoomWizars(models.TransientModel):
|
||||
_name = 'hotel.virtual.room.wizard'
|
||||
|
||||
class HotelRoomTypeWizards(models.TransientModel):
|
||||
_name = 'hotel.room.type.wizard'
|
||||
|
||||
@api.multi
|
||||
def _get_default_checkin(self):
|
||||
@@ -313,8 +289,8 @@ class VirtualRoomWizars(models.TransientModel):
|
||||
def _get_default_checkout(self):
|
||||
return self.folio_wizard_id.checkout
|
||||
|
||||
virtual_room_id = fields.Many2one('hotel.room.type',
|
||||
string="Virtual Rooms")
|
||||
room_type_id = fields.Many2one('hotel.room.type',
|
||||
string="Virtual Rooms")
|
||||
rooms_num = fields.Integer('Number of Rooms')
|
||||
max_rooms = fields.Integer('Max', compute="_compute_max")
|
||||
price = fields.Float(string='Price by Room')
|
||||
@@ -346,15 +322,15 @@ class VirtualRoomWizars(models.TransientModel):
|
||||
date_end = date_utils.get_datetime(res.checkout)
|
||||
date_diff = date_utils.date_diff(date_start, date_end, hours=False)
|
||||
minstay_restrictions = self.env['hotel.room.type.restriction.item'].search([
|
||||
('virtual_room_id','=',res.virtual_room_id.id),
|
||||
('room_type_id','=',res.room_type_id.id),
|
||||
])
|
||||
avail_restrictions = self.env['hotel.room.type.availability'].search([
|
||||
('virtual_room_id','=',res.virtual_room_id.id)
|
||||
('room_type_id','=',res.room_type_id.id)
|
||||
])
|
||||
real_max = len(res.virtual_room_id.check_availability_virtual_room(
|
||||
res.checkin,
|
||||
res.checkout,
|
||||
res.virtual_room_id.id))
|
||||
real_max = len(res.room_type_id.check_availability_room(
|
||||
res.checkin,
|
||||
res.checkout,
|
||||
res.room_type_id.id))
|
||||
avail = 100000
|
||||
min_stay = 0
|
||||
dates = []
|
||||
@@ -364,67 +340,59 @@ class VirtualRoomWizars(models.TransientModel):
|
||||
dates.append(ndate_str)
|
||||
if minstay_restrictions:
|
||||
date_min_days = minstay_restrictions.filtered(
|
||||
lambda r: r.date_start <= ndate_str and \
|
||||
r.date_end >= ndate_str).min_stay
|
||||
lambda r: r.date_start <= ndate_str and \
|
||||
r.date_end >= ndate_str).min_stay
|
||||
if date_min_days > min_stay:
|
||||
min_stay = date_min_days
|
||||
if user.has_group('hotel.group_hotel_call'):
|
||||
if avail_restrictions:
|
||||
max_avail = avail_restrictions.filtered(
|
||||
lambda r: r.date == ndate_str).wmax_avail
|
||||
lambda r: r.date == ndate_str).wmax_avail
|
||||
if max_avail < avail:
|
||||
avail = min(max_avail, real_max)
|
||||
else:
|
||||
avail = real_max
|
||||
|
||||
|
||||
if avail < 100000 and avail > 0:
|
||||
if 100000 < avail > 0:
|
||||
res.max_rooms = avail
|
||||
else:
|
||||
res.max_rooms = 0
|
||||
if min_stay > 0:
|
||||
res.min_stay = min_stay
|
||||
|
||||
@api.onchange('rooms_num', 'discount', 'price','virtual_room_id',
|
||||
'checkin','checkout')
|
||||
@api.onchange('rooms_num', 'discount', 'price', 'room_type_id', 'checkin', 'checkout')
|
||||
def update_price(self):
|
||||
for line in self:
|
||||
now_utc_dt = date_utils.now()
|
||||
if not self.checkin:
|
||||
self.checkin = self.folio_wizard_id.checkin
|
||||
if not self.checkout:
|
||||
self.checkout = self.folio_wizard_id.checkout
|
||||
if self.rooms_num > self.max_rooms:
|
||||
for record in self:
|
||||
checkin = record.checkin or record.folio_wizard_id.checkin
|
||||
checkout = record.checkout or record.folio_wizard_id.checkout
|
||||
if record.rooms_num > record.max_rooms:
|
||||
raise ValidationError(_("There are not enough rooms!"))
|
||||
# UTC -> Hotel tz
|
||||
tz = self.env['ir.default'].sudo().get('res.config.settings',
|
||||
'tz_hotel')
|
||||
chkin_utc_dt = date_utils.get_datetime(self.checkin)
|
||||
chkout_utc_dt = date_utils.get_datetime(self.checkout)
|
||||
chkin_utc_dt = date_utils.get_datetime(checkin)
|
||||
chkout_utc_dt = date_utils.get_datetime(checkout)
|
||||
|
||||
if chkin_utc_dt >= chkout_utc_dt:
|
||||
dpt_hour = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'default_departure_hour')
|
||||
checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
checkout_str = "%s %s:00" % (checkout_str, dpt_hour)
|
||||
checkout_dt = date_utils.get_datetime(checkout_str, stz=tz)
|
||||
checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC')
|
||||
self.checkout = checkout_utc_dt.strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
checkout_dt = date_utils.get_datetime(self.checkout, stz=tz)
|
||||
checkout = checkout_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
checkout_dt = date_utils.get_datetime(checkout, stz=tz)
|
||||
# Reservation end day count as free day. Not check it
|
||||
checkout_dt -= timedelta(days=1)
|
||||
nights = days_diff = date_utils.date_diff(self.checkin,
|
||||
self.checkout,
|
||||
hours=False)
|
||||
start_date_dt = date_utils.dt_as_timezone(chkin_utc_dt,
|
||||
tz)
|
||||
nights = date_utils.date_diff(checkin, checkout, hours=False)
|
||||
start_date_dt = date_utils.dt_as_timezone(chkin_utc_dt, tz)
|
||||
# Reservation end day count as free day. Not check it
|
||||
checkout_dt -= timedelta(days=1)
|
||||
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
|
||||
@@ -432,24 +400,31 @@ class VirtualRoomWizars(models.TransientModel):
|
||||
for i in range(0, nights):
|
||||
ndate = start_date_dt + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod = self.virtual_room_id.product_id.with_context(
|
||||
lang=self.folio_wizard_id.partner_id.lang,
|
||||
partner=self.folio_wizard_id.partner_id.id,
|
||||
prod = record.room_type_id.product_id.with_context(
|
||||
lang=record.folio_wizard_id.partner_id.lang,
|
||||
partner=record.folio_wizard_id.partner_id.id,
|
||||
quantity=1,
|
||||
date=ndate_str,
|
||||
pricelist=pricelist_id,
|
||||
uom=self.virtual_room_id.product_id.uom_id.id)
|
||||
uom=record.room_type_id.product_id.uom_id.id)
|
||||
res_price += prod.price
|
||||
self.price = res_price - (res_price * self.discount)/100
|
||||
self.total_price = self.rooms_num * self.price
|
||||
self.amount_reservation = self.total_price
|
||||
|
||||
price = (res_price * record.discount) * 0.01
|
||||
total_price = record.rooms_num * price
|
||||
record.write({
|
||||
'checkin': checkin,
|
||||
'checkout': checkout,
|
||||
'price': price,
|
||||
'total_price': total_price,
|
||||
'amount_reservation': total_price,
|
||||
})
|
||||
|
||||
|
||||
class ReservationWizard(models.TransientModel):
|
||||
_name = 'hotel.reservation.wizard'
|
||||
|
||||
product_id = fields.Many2one('product.product',
|
||||
string="Virtual Rooms")
|
||||
string="Room Types")
|
||||
|
||||
folio_wizard_id = fields.Many2one('hotel.folio.wizard')
|
||||
|
||||
@@ -459,9 +434,9 @@ class ReservationWizard(models.TransientModel):
|
||||
help='Number of children there in guest list.')
|
||||
checkin = fields.Datetime('Check In', required=True)
|
||||
checkout = fields.Datetime('Check Out', required=True)
|
||||
virtual_room_id = fields.Many2one('hotel.room.type',
|
||||
string='Virtual Room Type',
|
||||
required=True)
|
||||
room_type_id = fields.Many2one('hotel.room.type',
|
||||
string='Virtual Room Type',
|
||||
required=True)
|
||||
nights = fields.Integer('Nights', readonly=True)
|
||||
price = fields.Float(string='Total')
|
||||
amount_reservation = fields.Float(string='Total', readonly=True)
|
||||
@@ -483,11 +458,11 @@ class ReservationWizard(models.TransientModel):
|
||||
for line in self:
|
||||
if line.checkin and line.checkout:
|
||||
room = self.env['hotel.room'].search([
|
||||
('product_id.id','=',line.product_id.id)
|
||||
('product_id.id', '=', line.product_id.id)
|
||||
])
|
||||
if line.adults == 0:
|
||||
line.adults = room.capacity
|
||||
line.virtual_room_id = room.price_virtual_room.id
|
||||
line.room_type_id = room.price_room_type.id
|
||||
checkout_dt = date_utils.get_datetime(line.checkout)
|
||||
checkout_dt -= timedelta(days=1)
|
||||
occupied = self.env['hotel.reservation'].occupied(
|
||||
@@ -495,10 +470,11 @@ class ReservationWizard(models.TransientModel):
|
||||
checkout_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
rooms_occupied = occupied.mapped('product_id.id')
|
||||
if line.product_id.id in rooms_occupied:
|
||||
raise ValidationError(_("This room is occupied!, please, choice other room or change the reservation date"))
|
||||
raise ValidationError(_("This room is occupied!, please, \
|
||||
choice other room or change the reservation date"))
|
||||
|
||||
@api.multi
|
||||
@api.onchange('checkin', 'checkout', 'virtual_room_id', 'discount')
|
||||
@api.onchange('checkin', 'checkout', 'room_type_id', 'discount')
|
||||
def onchange_dates(self):
|
||||
for line in self:
|
||||
if not self.checkin:
|
||||
@@ -512,20 +488,19 @@ class ReservationWizard(models.TransientModel):
|
||||
start_date_dt = date_utils.dt_as_timezone(start_date_utc_dt,
|
||||
hotel_tz)
|
||||
|
||||
if line.virtual_room_id:
|
||||
if line.room_type_id:
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
nights = days_diff = date_utils.date_diff(line.checkin,
|
||||
line.checkout,
|
||||
hours=False)
|
||||
nights = date_utils.date_diff(line.checkin,
|
||||
line.checkout,
|
||||
hours=False)
|
||||
res_price = 0
|
||||
res_partner = self.partner_id or self.env['res.partner'].browse('1')
|
||||
for i in range(0, nights):
|
||||
ndate = start_date_dt + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod = line.virtual_room_id.product_id.with_context(
|
||||
prod = line.room_type_id.product_id.with_context(
|
||||
lang=self.partner_id.lang,
|
||||
partner=self.partner_id.id,
|
||||
quantity=1,
|
||||
@@ -533,10 +508,7 @@ class ReservationWizard(models.TransientModel):
|
||||
pricelist=pricelist_id,
|
||||
uom=line.product_id.uom_id.id)
|
||||
res_price += prod.price
|
||||
adults = self.env['hotel.room'].search([
|
||||
('product_id.id', '=', line.product_id.id)
|
||||
]).capacity
|
||||
res_price = res_price - (res_price * self.discount)/100
|
||||
res_price = res_price - (res_price * self.discount) * 0.01
|
||||
line.amount_reservation = res_price
|
||||
line.price = res_price
|
||||
checkout_dt = date_utils.get_datetime(self.checkout)
|
||||
@@ -551,34 +523,41 @@ class ReservationWizard(models.TransientModel):
|
||||
]
|
||||
return {'domain': {'product_id': domain_rooms}}
|
||||
|
||||
|
||||
class ServiceWizard(models.TransientModel):
|
||||
_name = 'hotel.service.wizard'
|
||||
|
||||
product_id = fields.Many2one('product.product',
|
||||
string="Service")
|
||||
string="Service")
|
||||
folio_wizard_id = fields.Many2one('hotel.folio.wizard')
|
||||
discount = fields.Float('discount')
|
||||
price_unit = fields.Float('Unit Price', required=True, digits=dp.get_precision('Product Price'), default=0.0)
|
||||
price_total = fields.Float(compute='_compute_amount', string='Subtotal', readonly=True, store=True)
|
||||
product_uom_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True, default=1.0)
|
||||
price_unit = fields.Float('Unit Price', required=True,
|
||||
digits=dp.get_precision('Product Price'),
|
||||
default=0.0)
|
||||
price_total = fields.Float(compute='_compute_amount', string='Subtotal',
|
||||
readonly=True, store=True)
|
||||
product_uom_qty = fields.Float(string='Quantity',
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
required=True,
|
||||
default=1.0)
|
||||
|
||||
@api.onchange('product_id')
|
||||
def onchange_product_id(self):
|
||||
if self.product_id:
|
||||
#TODO change pricelist for partner
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
'res.config.settings', 'parity_pricelist_id')
|
||||
prod = self.product_id.with_context(
|
||||
lang=self.folio_wizard_id.partner_id.lang,
|
||||
partner=self.folio_wizard_id.partner_id.id,
|
||||
quantity=1,
|
||||
date=fields.Datetime.now(),
|
||||
pricelist=pricelist_id,
|
||||
uom=self.product_id.uom_id.id)
|
||||
lang=self.folio_wizard_id.partner_id.lang,
|
||||
partner=self.folio_wizard_id.partner_id.id,
|
||||
quantity=1,
|
||||
date=fields.Datetime.now(),
|
||||
pricelist=pricelist_id,
|
||||
uom=self.product_id.uom_id.id)
|
||||
self.price_unit = prod.price
|
||||
|
||||
@api.depends('price_unit', 'product_uom_qty', 'discount')
|
||||
def _compute_amount(self):
|
||||
for ser in self:
|
||||
total = (ser.price_unit * ser.product_uom_qty)
|
||||
ser.price_total = total - (total * ser.discount) / 100
|
||||
ser.price_total = total - (total * ser.discount) * 0.01
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="virtual_room_wizard_ids" nolabel="1"
|
||||
<field name="room_type_wizard_ids" nolabel="1"
|
||||
attrs="{'invisible': [('autoassign','=',False)]}">
|
||||
<tree editable="bottom" create="false" delete="false"
|
||||
decoration-danger="max_rooms < rooms_num"
|
||||
@@ -27,7 +27,7 @@
|
||||
decoration-success="max_rooms >= rooms_num and rooms_num > 0">
|
||||
<field name="min_stay" />
|
||||
<field name="max_rooms" />
|
||||
<field name="virtual_room_id" string="Room Type" readonly="1"/>
|
||||
<field name="room_type_id" string="Room Type" readonly="1"/>
|
||||
<field name="rooms_num" attrs="{'readonly': [('can_confirm','=',False)]}" />
|
||||
<field name="checkin" widget="date" />
|
||||
<field name="checkout" widget="date" />
|
||||
@@ -50,7 +50,7 @@
|
||||
nolabel="1" attrs="{'invisible': [('autoassign','=',True)]}">
|
||||
<tree string="Room Line" delete="false" editable="buttom">
|
||||
<field name="product_id" string="Room No" options="{'no_create': True}"/>
|
||||
<field name="virtual_room_id" options="{'no_create': True}" />
|
||||
<field name="room_type_id" options="{'no_create': True}" />
|
||||
<field name="checkin" />
|
||||
<field name="checkout" />
|
||||
<field name="nights" />
|
||||
|
||||
@@ -84,10 +84,10 @@ class HotelReservation(models.Model):
|
||||
'reserve_color_text': record.reserve_color_text,
|
||||
'splitted': record.splitted,
|
||||
'parent_reservation': record.parent_reservation and
|
||||
record.parent_reservation.id or 0,
|
||||
record.parent_reservation.id or 0,
|
||||
'room_name': record.product_id.name,
|
||||
'partner_phone': record.partner_id.mobile
|
||||
or record.partner_id.phone or _('Undefined'),
|
||||
'partner_phone': record.partner_id.mobile or
|
||||
record.partner_id.phone or _('Undefined'),
|
||||
'state': record.state,
|
||||
'fix_days': record.splitted or record.is_from_ota,
|
||||
'overbooking': record.overbooking,
|
||||
@@ -98,6 +98,6 @@ class HotelReservation(models.Model):
|
||||
@api.multi
|
||||
def confirm(self):
|
||||
for record in self:
|
||||
if record.to_assign == True:
|
||||
if record.to_assign:
|
||||
record.write({'to_read': False, 'to_assign': False})
|
||||
return super(HotelReservation, self).confirm()
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<field name="partner_id"/>
|
||||
<field name="splitted" invisible="1" />
|
||||
<field name="parent_reservation" invisible="1" />
|
||||
<field name="virtual_room_id" string="Reserved Room Type"/>
|
||||
<field name="room_type_id" string="Reserved Room Type"/>
|
||||
<field name="nights" />
|
||||
<field name="to_read" invisible="1"/>
|
||||
<field name="adults" string="Persons"/>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
'views/general.xml',
|
||||
'views/inherited_hotel_reservation_views.xml',
|
||||
'views/inherited_hotel_room_type_views.xml',
|
||||
'views/inherited_hotel_virtual_room_availability_views.xml',
|
||||
'views/inherited_hotel_room_type_availability_views.xml',
|
||||
'views/inherited_hotel_folio_views.xml',
|
||||
'views/inherited_product_pricelist_views.xml',
|
||||
'views/inherited_product_pricelist_item_views.xml',
|
||||
@@ -36,8 +36,8 @@
|
||||
'views/wubook_issue_views.xml',
|
||||
'views/channel_hotel_reservation_views.xml',
|
||||
'views/channel_hotel_room_type_views.xml',
|
||||
'views/channel_hotel_virtual_room_availability_views.xml',
|
||||
'views/channel_hotel_virtual_room_restriction_views.xml',
|
||||
'views/channel_hotel_room_type_availability_views.xml',
|
||||
'views/channel_hotel_room_type_restriction_views.xml',
|
||||
'views/channel_product_pricelist_views.xml',
|
||||
'data/menus.xml',
|
||||
'data/sequences.xml',
|
||||
|
||||
@@ -29,11 +29,11 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
DEFAULT_SERVER_DATE_FORMAT))
|
||||
])
|
||||
|
||||
vrooms = vroom_avail_ids.mapped('virtual_room_id')
|
||||
vrooms = vroom_avail_ids.mapped('room_type_id')
|
||||
avails = []
|
||||
for vroom in vrooms:
|
||||
vroom_avails = vroom_avail_ids.filtered(
|
||||
lambda x: x.virtual_room_id.id == vroom.id)
|
||||
lambda x: x.room_type_id.id == vroom.id)
|
||||
days = []
|
||||
for vroom_avail in vroom_avails:
|
||||
vroom_avail.with_context({
|
||||
@@ -139,8 +139,8 @@ class HotelChannelConnectorExporter(AbstractComponent):
|
||||
('wpushed', '=', False),
|
||||
('restriction_id', '=', rp.id)
|
||||
])
|
||||
virtual_room_ids = unpushed_rp.mapped('virtual_room_id')
|
||||
for vroom in virtual_room_ids:
|
||||
room_type_ids = unpushed_rp.mapped('room_type_id')
|
||||
for vroom in room_type_ids:
|
||||
restrictions[rp.wpid].update({vroom.wrid: []})
|
||||
for i in range(0, days_diff):
|
||||
ndate_dt = date_start + timedelta(days=i)
|
||||
|
||||
@@ -17,9 +17,9 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def _get_room_values_availability(self, vroom_id, date_str, day_vals, set_max_avail):
|
||||
virtual_room_avail_obj = self.env['hotel.room.type.availability']
|
||||
vroom_avail = virtual_room_avail_obj.search([
|
||||
('virtual_room_id', '=', vroom_id),
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
vroom_avail = room_type_avail_obj.search([
|
||||
('room_type_id', '=', vroom_id),
|
||||
('date', '=', date_str)
|
||||
], limit=1)
|
||||
vals = {
|
||||
@@ -36,10 +36,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
}).write(vals)
|
||||
else:
|
||||
vals.update({
|
||||
'virtual_room_id': vroom_id,
|
||||
'room_type_id': vroom_id,
|
||||
'date': date_str,
|
||||
})
|
||||
virtual_room_avail_obj.with_context({
|
||||
room_type_avail_obj.with_context({
|
||||
'wubook_action': False,
|
||||
'mail_create_nosubscribe': True,
|
||||
}).create(vals)
|
||||
@@ -48,8 +48,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
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([
|
||||
('virtual_room_id', '=', vroom_id),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('room_type_id', '=', vroom_id),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('date_start', '=', date_str),
|
||||
('date_end', '=', date_str),
|
||||
('restriction_id', '=', restriction_plan_id),
|
||||
@@ -79,10 +79,10 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
else:
|
||||
vals.update({
|
||||
'restriction_id': restriction_plan_id,
|
||||
'virtual_room_id': vroom_id,
|
||||
'room_type_id': vroom_id,
|
||||
'date_start': date_str,
|
||||
'date_end': date_str,
|
||||
'applied_on': '0_virtual_room',
|
||||
'applied_on': '0_room_type',
|
||||
})
|
||||
vroom_restr_item_obj.with_context({
|
||||
'wubook_action': False,
|
||||
@@ -90,13 +90,13 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def _generate_room_values(self, dfrom, dto, values, set_max_avail=False):
|
||||
virtual_room_restr_obj = self.env['hotel.room.type.restriction']
|
||||
hotel_virtual_room_obj = self.env['hotel.room.type']
|
||||
def_restr_plan = virtual_room_restr_obj.search([('wpid', '=', '0')])
|
||||
room_type_restr_obj = self.env['hotel.room.type.restriction']
|
||||
hotel_room_type_obj = self.env['hotel.room.type']
|
||||
def_restr_plan = room_type_restr_obj.search([('wpid', '=', '0')])
|
||||
_logger.info("==== ROOM VALUES (%s -- %s)", dfrom, dto)
|
||||
_logger.info(values)
|
||||
for k_rid, v_rid in values.iteritems():
|
||||
vroom = hotel_virtual_room_obj.search([
|
||||
vroom = hotel_room_type_obj.search([
|
||||
('wrid', '=', k_rid)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
@@ -159,7 +159,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
'wstatus': wstatus,
|
||||
'to_read': True,
|
||||
'state': is_cancellation and 'cancelled' or 'draft',
|
||||
'virtual_room_id': vroom.id,
|
||||
'room_type_id': vroom.id,
|
||||
'splitted': split_booking,
|
||||
'wbook_json': json.dumps(book),
|
||||
'wmodified': book['was_modified']
|
||||
@@ -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_virtual_room(
|
||||
free_rooms = hotel_vroom_obj.check_availability_room(
|
||||
checkin_str,
|
||||
checkout_str,
|
||||
virtual_room_id=vroom.id,
|
||||
room_type_id=vroom.id,
|
||||
notthis=used_rooms)
|
||||
if any(free_rooms):
|
||||
vals.update({
|
||||
@@ -515,7 +515,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def _generate_pricelist_items(self, channel_plan_id, date_from, date_to, plan_prices):
|
||||
hotel_virtual_room_obj = self.env['hotel.room.type']
|
||||
hotel_room_type_obj = self.env['hotel.room.type']
|
||||
pricelist = self.env['product.pricelist'].search([
|
||||
('wpid', '=', channel_plan_id)
|
||||
], limit=1)
|
||||
@@ -527,7 +527,7 @@ 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_virtual_room_obj.search([
|
||||
vroom = hotel_room_type_obj.search([
|
||||
('wrid', '=', k_rid)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
@@ -589,7 +589,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
|
||||
@api.model
|
||||
def _generate_restriction_items(self, plan_restrictions):
|
||||
hotel_virtual_room_obj = self.env['hotel.room.type']
|
||||
hotel_room_type_obj = self.env['hotel.room.type']
|
||||
reserv_restriction_obj = self.env['hotel.room.type.restriction']
|
||||
restriction_item_obj = self.env['hotel.room.type.restriction.item']
|
||||
_logger.info("===== RESTRICTIONS")
|
||||
@@ -600,7 +600,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
], limit=1)
|
||||
if restriction_id:
|
||||
for k_rid, v_rid in v_rpid.iteritems():
|
||||
vroom = hotel_virtual_room_obj.search([
|
||||
vroom = hotel_room_type_obj.search([
|
||||
('wrid', '=', k_rid)
|
||||
], limit=1)
|
||||
if vroom:
|
||||
@@ -614,8 +614,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('date_end', '=', date_dt.strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('virtual_room_id', '=', vroom.id)
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('room_type_id', '=', vroom.id)
|
||||
], limit=1)
|
||||
vals = {
|
||||
'closed_arrival': item['closed_arrival'],
|
||||
@@ -637,8 +637,8 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
DEFAULT_SERVER_DATE_FORMAT),
|
||||
'date_end': date_dt.strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT),
|
||||
'applied_on': '0_virtual_room',
|
||||
'virtual_room_id': vroom.id
|
||||
'applied_on': '0_room_type',
|
||||
'room_type_id': vroom.id
|
||||
})
|
||||
restriction_item_obj.with_context({
|
||||
'wubook_action': False}).create(vals)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record model="ir.sequence" id="seq_vroom_id">
|
||||
<record model="ir.sequence" id="seq_room_type_id">
|
||||
<field name="name">Virtual Room Short Code</field>
|
||||
<field name="code">hotel.virtual.room</field>
|
||||
<field name="code">hotel.room.type</field>
|
||||
<field name="prefix"></field>
|
||||
<field name="padding">4</field>
|
||||
</record>
|
||||
|
||||
@@ -7,9 +7,9 @@ from . import res_config
|
||||
from . import hotel_room_type
|
||||
from . import product_pricelist
|
||||
from . import inherited_product_pricelist_item
|
||||
from . import hotel_virtual_room_restriction
|
||||
from . import hotel_room_type_restriction
|
||||
from . import inherited_reservation_restriction_item
|
||||
from . import hotel_virtual_room_availability
|
||||
from . import hotel_room_type_availability
|
||||
from . import hotel_reservation
|
||||
from . import inherited_hotel_folio
|
||||
from . import inherited_res_partner
|
||||
|
||||
@@ -121,7 +121,7 @@ class HotelRoomType(models.Model):
|
||||
restriction = self.env['hotel.room.type.restriction.item'].search([
|
||||
('date_start', '=', date),
|
||||
('date_end', '=', date),
|
||||
('virtual_room_id', '=', self.id),
|
||||
('room_type_id', '=', self.id),
|
||||
('restriction_id', '=', restriction_plan_id)
|
||||
], limit=1)
|
||||
return restriction
|
||||
|
||||
@@ -6,7 +6,7 @@ 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
|
||||
|
||||
class ChannelHotelVirtualRoomAvailability(models.Model):
|
||||
class ChannelHotelRoomTypeAvailability(models.Model):
|
||||
_name = 'channel.hotel.room.type.availability'
|
||||
_inherit = 'channel.binding'
|
||||
_inherits = {'hotel.room.type.availability': 'odoo_id'}
|
||||
@@ -14,8 +14,8 @@ class ChannelHotelVirtualRoomAvailability(models.Model):
|
||||
|
||||
@api.model
|
||||
def _default_channel_max_avail(self):
|
||||
if self.virtual_room_id:
|
||||
return self.virtual_room_id.max_real_rooms
|
||||
if self.room_type_id:
|
||||
return self.room_type_id.max_real_rooms
|
||||
return -1
|
||||
|
||||
odoo_id = fields.Many2one(comodel_names='product.pricelist',
|
||||
@@ -31,10 +31,10 @@ class ChannelHotelVirtualRoomAvailability(models.Model):
|
||||
@api.constrains('channel_max_avail')
|
||||
def _check_wmax_avail(self):
|
||||
for record in self:
|
||||
if record.channel_max_avail > record.virtual_room_id.total_rooms_count:
|
||||
if record.channel_max_avail > record.room_type_id.total_rooms_count:
|
||||
raise ValidationError(_("max avail for channel can't be high \
|
||||
than toal rooms \
|
||||
count: %d") % record.virtual_room_id.total_rooms_count)
|
||||
count: %d") % record.room_type_id.total_rooms_count)
|
||||
|
||||
@job(default_channel='root.channel')
|
||||
@related_action(action='related_action_unwrap_binding')
|
||||
@@ -46,40 +46,40 @@ class ChannelHotelVirtualRoomAvailability(models.Model):
|
||||
adapter = work.component(usage='backend.adapter')
|
||||
date_dt = date_utils.get_datetime(self.date)
|
||||
adapter.update_availability([{
|
||||
'id': self.virtual_room_id.channel_room_id,
|
||||
'id': self.room_type_id.channel_room_id,
|
||||
'days': [{
|
||||
'date': date_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||
'avail': self.avail,
|
||||
}],
|
||||
}])
|
||||
|
||||
class HotelVirtualRoomAvailability(models.Model):
|
||||
class HotelRoomTypeAvailability(models.Model):
|
||||
_inherit = 'hotel.room.type.availability'
|
||||
|
||||
channel_bind_ids = fields.One2many(
|
||||
comodel_name='channel.hotel.room.type.availability',
|
||||
inverse_name='odoo_id',
|
||||
string='Hotel Virtual Room Availability Connector Bindings')
|
||||
string='Hotel Room Type Availability Connector Bindings')
|
||||
|
||||
@api.constrains('avail')
|
||||
def _check_avail(self):
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
issue_obj = self.env['hotel.channel.connector.issue']
|
||||
for record in self:
|
||||
cavail = len(vroom_obj.check_availability_virtual_room(
|
||||
cavail = len(vroom_obj.check_availability_room(
|
||||
record.date,
|
||||
record.date,
|
||||
virtual_room_id=record.virtual_room_id.id))
|
||||
max_avail = min(cavail, record.virtual_room_id.total_rooms_count)
|
||||
room_type_id=record.room_type_id.id))
|
||||
max_avail = min(cavail, record.room_type_id.total_rooms_count)
|
||||
if record.avail > max_avail:
|
||||
issue_obj.sudo().create({
|
||||
'section': 'avail',
|
||||
'message': _(r"The new availability can't be greater than \
|
||||
the actual availability \
|
||||
\n[%s]\nInput: %d\Limit: %d") % (record.virtual_room_id.name,
|
||||
\n[%s]\nInput: %d\Limit: %d") % (record.room_type_id.name,
|
||||
record.avail,
|
||||
record),
|
||||
'wid': record.virtual_room_id.wrid,
|
||||
'wid': record.room_type_id.wrid,
|
||||
'date_start': record.date,
|
||||
'date_end': record.date,
|
||||
})
|
||||
@@ -87,10 +87,10 @@ class HotelVirtualRoomAvailability(models.Model):
|
||||
self._event('on_fix_channel_availability').notify(record)
|
||||
return super(HotelVirtualRoomAvailability, self)._check_avail()
|
||||
|
||||
@api.onchange('virtual_room_id')
|
||||
def onchange_virtual_room_id(self):
|
||||
if self.virtual_room_id:
|
||||
self.channel_max_avail = self.virtual_room_id.max_real_rooms
|
||||
@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
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
@@ -105,7 +105,7 @@ class HotelVirtualRoomAvailability(models.Model):
|
||||
date_diff = date_utils.date_diff(checkin, checkout, hours=False)
|
||||
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
virtual_room_avail_obj = self.env['hotel.room.type.availability']
|
||||
room_type_avail_obj = self.env['hotel.room.type.availability']
|
||||
|
||||
vrooms = vroom_obj.search([
|
||||
('room_ids.product_id', '=', product_id)
|
||||
@@ -115,29 +115,29 @@ class HotelVirtualRoomAvailability(models.Model):
|
||||
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_virtual_room(
|
||||
avail = len(vroom_obj.check_availability_room(
|
||||
ndate_str,
|
||||
ndate_str,
|
||||
virtual_room_id=vroom.id))
|
||||
room_type_id=vroom.id))
|
||||
max_avail = vroom.max_real_rooms
|
||||
vroom_avail_id = virtual_room_avail_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
vroom_avail_id = room_type_avail_obj.search([
|
||||
('room_type_id', '=', vroom.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
|
||||
avail = max(
|
||||
min(avail, vroom.total_rooms_count, max_avail), 0)
|
||||
min(avail, vroom.total_rooms_count, max_avail), 0)
|
||||
|
||||
if vroom_avail_id:
|
||||
vroom_avail_id.write({'avail': avail})
|
||||
else:
|
||||
virtual_room_avail_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
room_type_avail_obj.create({
|
||||
'room_type_id': vroom.id,
|
||||
'date': ndate_str,
|
||||
'avail': avail,
|
||||
})
|
||||
|
||||
class ChannelBindingHotelVirtualRoomAvailabilityListener(Component):
|
||||
class ChannelBindingHotelRoomTypeAvailabilityListener(Component):
|
||||
_name = 'channel.binding.hotel.room.type.availability.listener'
|
||||
_inherit = 'base.connector.listener'
|
||||
_apply_on = ['channel.hotel.room.type.availability']
|
||||
@@ -6,11 +6,11 @@ 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
|
||||
|
||||
class ChannelHotelVirtualRoomRestriction(models.Model):
|
||||
class ChannelHotelRoomTypeRestriction(models.Model):
|
||||
_name = 'channel.hotel.room.type.restriction'
|
||||
_inherit = 'channel.binding'
|
||||
_inherits = {'hotel.room.type.restriction': 'odoo_id'}
|
||||
_description = 'Channel Hotel Virtual Room Restriction'
|
||||
_description = 'Channel Hotel Room Type Restriction'
|
||||
|
||||
odoo_id = fields.Many2one(comodel_names='hotel.room.type.restriction',
|
||||
string='Hotel Virtual Room Restriction',
|
||||
@@ -70,7 +70,7 @@ class ChannelHotelVirtualRoomRestriction(models.Model):
|
||||
importer = work.component(usage='channel.importer')
|
||||
return importer.import_restriction_plans()
|
||||
|
||||
class HotelVirtualRoomRestriction(models.Model):
|
||||
class HotelRoomTypeRestriction(models.Model):
|
||||
_inherit = 'hotel.room.type.restriction'
|
||||
|
||||
channel_bind_ids = fields.One2many(
|
||||
@@ -92,7 +92,7 @@ class HotelVirtualRoomRestriction(models.Model):
|
||||
names.append((name[0], name[1]))
|
||||
return names
|
||||
|
||||
class ChannelBindingHotelVirtualRoomRestrictionListener(Component):
|
||||
class ChannelBindingHotelRoomTypeRestrictionListener(Component):
|
||||
_name = 'channel.binding.hotel.room.type.restriction.listener'
|
||||
_inherit = 'base.connector.listener'
|
||||
_apply_on = ['channel.hotel.room.type.restriction']
|
||||
@@ -48,11 +48,11 @@ class HotelFolio(models.Model):
|
||||
dates = rline.get_real_checkin_checkout()
|
||||
vals = {
|
||||
'num': len(
|
||||
self.room_lines.filtered(lambda r: r.get_real_checkin_checkout()[0] == dates[0] and r.get_real_checkin_checkout()[1] == dates[1] and r.virtual_room_id.id == rline.virtual_room_id.id and (r.to_send or import_all) and not r.parent_reservation and r.state == rline.state and ((r.state == 'cancelled' and not r.channel_modified) or r.state != 'cancelled'))
|
||||
self.room_lines.filtered(lambda r: r.get_real_checkin_checkout()[0] == dates[0] and r.get_real_checkin_checkout()[1] == dates[1] and r.room_type_id.id == rline.room_type_id.id and (r.to_send or import_all) and not r.parent_reservation and r.state == rline.state and ((r.state == 'cancelled' and not r.channel_modified) or r.state != 'cancelled'))
|
||||
),
|
||||
'virtual_room': {
|
||||
'id': rline.virtual_room_id.id,
|
||||
'name': rline.virtual_room_id.name,
|
||||
'room_type': {
|
||||
'id': rline.room_type_id.id,
|
||||
'name': rline.room_type_id.name,
|
||||
},
|
||||
'checkin': dates[0],
|
||||
'checkout': dates[1],
|
||||
@@ -62,13 +62,13 @@ class HotelFolio(models.Model):
|
||||
}
|
||||
founded = False
|
||||
for srline in info_grouped:
|
||||
if srline['num'] == vals['num'] and srline['virtual_room']['id'] == vals['virtual_room']['id'] and srline['checkin'] == vals['checkin'] and srline['checkout'] == vals['checkout']:
|
||||
if srline['num'] == vals['num'] and srline['room_type']['id'] == vals['room_type']['id'] and srline['checkin'] == vals['checkin'] and srline['checkout'] == vals['checkout']:
|
||||
founded = True
|
||||
break
|
||||
if not founded:
|
||||
info_grouped.append(vals)
|
||||
return sorted(sorted(info_grouped, key=lambda k: k['num'],
|
||||
reverse=True), key=lambda k: k['virtual_room']['id'])
|
||||
reverse=True), key=lambda k: k['room_type']['id'])
|
||||
|
||||
@api.depends('room_lines')
|
||||
def _compute_has_cancelled_reservations_to_send(self):
|
||||
|
||||
@@ -122,7 +122,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
vroom_restr_it_obj = self.env['hotel.room.type.restriction.item']
|
||||
# Secure Wubook Input
|
||||
restriction_item_ids = vroom_restr_it_obj.search([
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('date_start', '<', now_utc_str),
|
||||
])
|
||||
if any(restriction_item_ids):
|
||||
@@ -132,7 +132,7 @@ class HotelChannelConnectorConfiguration(models.TransientModel):
|
||||
# Put to push restrictions
|
||||
restriction_item_ids = vroom_restr_it_obj.search([
|
||||
('restriction_id', '=', restriction_id),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('applied_on', '=', '0_room_type'),
|
||||
('wpushed', '=', True),
|
||||
('date_start', '>=', now_utc_str),
|
||||
])
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
from . import test_wubook
|
||||
from . import test_virtual_room_availability_model
|
||||
from . import test_room_type_availability_model
|
||||
from . import test_wubook_issue_model
|
||||
from . import test_reservation_restriction_item_model
|
||||
from . import test_reservation_restriction_model
|
||||
@@ -31,5 +31,5 @@ from . import test_wubook_channel_info_model
|
||||
from . import test_product_pricelist_model
|
||||
from . import test_hotel_calendar_management_model
|
||||
from . import test_hotel_folio_model
|
||||
from . import test_hotel_virtual_room_model
|
||||
from . import test_hotel_room_type_model
|
||||
from . import test_hotel_reservation_model
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestVirtualRoomAvailability(TestHotelWubook):
|
||||
day_utc_dt = now_utc_dt + timedelta(days=1)
|
||||
vroom_avail_obj = self.env['hotel.room.type.availability']
|
||||
avail = vroom_avail_obj.search([
|
||||
('virtual_room_id', '=', self.hotel_vroom_budget.id),
|
||||
('room_type_id', '=', self.hotel_vroom_budget.id),
|
||||
('date', '=', now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
], limit=1)
|
||||
avail.write({
|
||||
|
||||
@@ -589,7 +589,7 @@ class TestWubook(TestHotelWubook):
|
||||
|
||||
for vroom in vrooms:
|
||||
items = vroom_restr_item_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
('room_type_id', '=', vroom.id),
|
||||
('date_start',
|
||||
'>=', checkin_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)),
|
||||
('date_end',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_form" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.virtual.room.form</field>
|
||||
<field name="model">channel.hotel.virtual.room</field>
|
||||
<record id="view_channel_hotel_room_type_form" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.form</field>
|
||||
<field name="model">channel.hotel.room.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Hotel Channel Virtual Room">
|
||||
<group>
|
||||
@@ -15,9 +15,9 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.virtual.room.tree</field>
|
||||
<field name="model">channel.hotel.virtual.room</field>
|
||||
<record id="view_channel_hotel_room_type_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.tree</field>
|
||||
<field name="model">channel.hotel.room.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Hotel Channel Virtual Room">
|
||||
<field name="backend_id"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_availability_form" model="ir.ui.view">
|
||||
<record id="view_channel_hotel_room_type_availability_form" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.availability.form</field>
|
||||
<field name="model">channel.hotel.room.type.availability</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -14,7 +14,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_availability_tree" model="ir.ui.view">
|
||||
<record id="view_channel_hotel_room_type_availability_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.availability.tree</field>
|
||||
<field name="model">channel.hotel.virtual.availability.room</field>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_restriction_form" model="ir.ui.view">
|
||||
<record id="view_channel_hotel_room_type_restriction_form" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.restriction.form</field>
|
||||
<field name="model">channel.hotel.room.type.restriction</field>
|
||||
<field name="arch" type="xml">
|
||||
@@ -14,7 +14,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_restriction_tree" model="ir.ui.view">
|
||||
<record id="view_channel_hotel_room_type_restriction_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.room.type.restriction.tree</field>
|
||||
<field name="model">channel.hotel.virtual.restriction.room</field>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_channel_hotel_virtual_room_restriction_tree" model="ir.ui.view">
|
||||
<record id="view_channel_hotel_room_type_restriction_tree" model="ir.ui.view">
|
||||
<field name="name">channel.hotel.product.pricelist.tree</field>
|
||||
<field name="model">channel.hotel.product.pricelist.room</field>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="virtual_room_view_form" model="ir.ui.view">
|
||||
<record id="room_type_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_room_type_form" />
|
||||
<field name="arch" type="xml">
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<odoo>
|
||||
|
||||
<!-- FORM availability -->
|
||||
<record id="virtual_room_availability_view_form" model="ir.ui.view">
|
||||
<record id="room_type_availability_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="inherit_id" ref="hotel.virtual_room_availability_view_form" />
|
||||
<field name="inherit_id" ref="hotel.room_type_availability_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//sheet" position="inside">
|
||||
<notebook>
|
||||
@@ -23,9 +23,9 @@
|
||||
</record>
|
||||
|
||||
<!-- TREE restriction -->
|
||||
<record id="virtual_room_availability_view_tree" model="ir.ui.view">
|
||||
<record id="room_type_availability_view_tree" model="ir.ui.view">
|
||||
<field name="model">hotel.room.type.availability</field>
|
||||
<field name="inherit_id" ref="hotel.virtual_room_availability_view_tree" />
|
||||
<field name="inherit_id" ref="hotel.room_type_availability_view_tree" />
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<!-- <xpath expr="//field[@name='avail']" position="after">
|
||||
|
||||
Reference in New Issue
Block a user