mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Merge branch '11.0' of https://github.com/hootel/hootel into 11.0
This commit is contained in:
@@ -353,7 +353,7 @@ class HotelReservation(models.Model):
|
||||
checkout = values.get('checkout')
|
||||
room_type = values.get('room_type_id')
|
||||
if checkin and checkout and room_type:
|
||||
room_chosen = self.env['hotel.room.type'].check_availability_room(checkin, checkout, room_type)[0]
|
||||
room_chosen = self.env['hotel.room.type'].check_availability_room_type(checkin, checkout, room_type)[0]
|
||||
# Check room_chosen exist
|
||||
res.update({
|
||||
'room_id': room_chosen.id
|
||||
|
||||
@@ -12,7 +12,7 @@ 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,
|
||||
@@ -51,7 +51,7 @@ class HotelRoomType(models.Model):
|
||||
for room in record.room_ids:
|
||||
if room.room_type_id and room.room_type_id != record.id:
|
||||
raise ValidationError(_("You need change de room type from de room form"))
|
||||
|
||||
|
||||
|
||||
@api.depends('room_ids')
|
||||
def _compute_total_rooms(self):
|
||||
@@ -74,8 +74,7 @@ class HotelRoomType(models.Model):
|
||||
return min(capacities) if any(capacities) else 0
|
||||
|
||||
@api.model
|
||||
# TODO Rename to check_availability_room_type
|
||||
def check_availability_room(self, dfrom, dto,
|
||||
def check_availability_room_type(self, dfrom, dto,
|
||||
room_type_id=False, notthis=[]):
|
||||
"""
|
||||
Check the avalability for an specific type of room
|
||||
|
||||
@@ -27,7 +27,7 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
record.avail = 0
|
||||
else:
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
cavail = len(room_type_obj.check_availability_room(
|
||||
cavail = len(room_type_obj.check_availability_room_type(
|
||||
record.date,
|
||||
record.date,
|
||||
room_type_id=record.room_type_id.id))
|
||||
|
||||
55
hotel/tests/test_hotel_room_type_model.py
Normal file
55
hotel/tests/test_hotel_room_type_model.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import timedelta
|
||||
from .common import TestHotel
|
||||
from odoo.addons.hotel import date_utils
|
||||
|
||||
|
||||
class TestHotelRoomType(TestHotel):
|
||||
|
||||
def test_cancel_folio(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
|
||||
org_reserv_start_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
org_reserv_end_utc_dt = org_reserv_start_utc_dt + timedelta(days=6)
|
||||
folio = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
reservation_a = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio,
|
||||
org_reserv_start_utc_dt,
|
||||
org_reserv_end_utc_dt,
|
||||
self.hotel_room_double_200,
|
||||
"Reservation Test #1")
|
||||
reservation_b = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio,
|
||||
org_reserv_start_utc_dt,
|
||||
org_reserv_end_utc_dt,
|
||||
self.hotel_room_simple_100,
|
||||
"Reservation Test #2")
|
||||
self.assertEqual(len(folio.room_lines), 2, 'Invalid room lines count')
|
||||
folio.action_cancel()
|
||||
self.assertEqual(folio.state, 'cancel', 'Invalid folio state')
|
||||
for rline in folio.room_lines:
|
||||
self.assertEqual(rline.state, 'cancelled',
|
||||
'Invalid reservation state')
|
||||
@@ -32,7 +32,7 @@ class DuplicateReservationWizard(models.TransientModel):
|
||||
}))
|
||||
|
||||
# Check Input
|
||||
avails = hotel_room_type_obj.check_availability_room(
|
||||
avails = hotel_room_type_obj.check_availability_room_type(
|
||||
reservation_id.checkin,
|
||||
reservation_id.checkout,
|
||||
room_type_id=reservation_id.room_type_id.id)
|
||||
@@ -43,7 +43,7 @@ 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_room(
|
||||
free_rooms = hotel_room_type_obj.check_availability_room_type(
|
||||
reservation_id.checkin,
|
||||
reservation_id.checkout,
|
||||
room_type_id=reservation_id.room_type_id.id)
|
||||
|
||||
@@ -192,7 +192,7 @@ class MassiveChangesWizard(models.TransientModel):
|
||||
hotel_room_type_obj = self.env['hotel.room.type']
|
||||
vals = {}
|
||||
if record.change_avail:
|
||||
cavail = len(hotel_room_type_obj.check_availability_room(
|
||||
cavail = len(hotel_room_type_obj.check_availability_room_type(
|
||||
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
room_type_id=room_type.id))
|
||||
|
||||
@@ -281,7 +281,7 @@ class HotelRoomTypeWizards(models.TransientModel):
|
||||
avail_restrictions = self.env['hotel.room.type.availability'].search([
|
||||
('room_type_id', '=', res.room_type_id.id)
|
||||
])
|
||||
real_max = len(res.room_type_id.check_availability_room(
|
||||
real_max = len(res.room_type_id.check_availability_room_type(
|
||||
res.checkin,
|
||||
res.checkout,
|
||||
res.room_type_id.id))
|
||||
|
||||
@@ -36,7 +36,7 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
@api.model
|
||||
def _get_availability_values(self, avail, room_type):
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
cavail = len(room_type_obj.check_availability_room(
|
||||
cavail = len(room_type_obj.check_availability_room_type(
|
||||
avail['date'], avail['date'], room_type_id=room_type.id))
|
||||
ravail = min(cavail, room_type.total_rooms_count, int(avail['avail']))
|
||||
vals = {
|
||||
@@ -251,7 +251,7 @@ class HotelCalendarManagement(models.TransientModel):
|
||||
json_data.setdefault(room_type.id, []).append({
|
||||
'date': cur_date_str,
|
||||
'num': len(
|
||||
room_type_obj.check_availability_room(
|
||||
room_type_obj.check_availability_room_type(
|
||||
cur_date_str,
|
||||
cur_date_str,
|
||||
room_type_id=room_type.id)),
|
||||
|
||||
@@ -367,7 +367,7 @@ class HotelChannelConnectorImporter(AbstractComponent):
|
||||
internal_message="Invalid reservation total price! %.2f != %.2f" % (vals['price_unit'], book['amount']),
|
||||
channel_object_id=book['reservation_code'])
|
||||
|
||||
free_rooms = room_type.odoo_id.check_availability_room(
|
||||
free_rooms = room_type.odoo_id.check_availability_room_type(
|
||||
checkin_str,
|
||||
checkout_str,
|
||||
room_type_id=room_type.odoo_id.id,
|
||||
|
||||
@@ -100,7 +100,7 @@ class HotelRoomTypeAvailability(models.Model):
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
issue_obj = self.env['hotel.channel.connector.issue']
|
||||
for record in self:
|
||||
cavail = len(room_type_obj.check_availability_room(
|
||||
cavail = len(room_type_obj.check_availability_room_type(
|
||||
record.date,
|
||||
record.date,
|
||||
room_type_id=record.room_type_id.id))
|
||||
@@ -143,7 +143,7 @@ class HotelRoomTypeAvailability(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(room_type_obj.check_availability_room(
|
||||
avail = len(room_type_obj.check_availability_room_type(
|
||||
ndate_str,
|
||||
ndate_str,
|
||||
room_type_id=room_type.id))
|
||||
|
||||
@@ -18,12 +18,12 @@ class HotelRoomType(models.Model):
|
||||
Check availability for all or specific room types between dates
|
||||
@return: A list of `ids` with free rooms
|
||||
"""
|
||||
free_rooms = super().check_availability_room(dfrom, dto, room_type_id, notthis)
|
||||
free_rooms = super().check_availability_room_type(dfrom, dto, room_type_id, notthis)
|
||||
return free_rooms.ids
|
||||
|
||||
@api.model
|
||||
def get_room_type_availability(self, dfrom, dto, room_type_id):
|
||||
free_rooms = self.check_availability_room(dfrom, dto)
|
||||
free_rooms = self.check_availability_room_type(dfrom, dto)
|
||||
availability_real = self.env['hotel.room'].search_count([
|
||||
('id', 'in', free_rooms.ids),
|
||||
('room_type_id', '=', room_type_id),
|
||||
|
||||
Reference in New Issue
Block a user