mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Merge branch '11.0' into hotel_node_master
This commit is contained in:
14
.travis.yml
14
.travis.yml
@@ -1,7 +1,7 @@
|
|||||||
language: python
|
language: python
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "3.5"
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
cache: pip
|
cache: pip
|
||||||
@@ -12,13 +12,10 @@ addons:
|
|||||||
packages:
|
packages:
|
||||||
- expect-dev # provides unbuffer utility
|
- expect-dev # provides unbuffer utility
|
||||||
- python-lxml # because pip installation is slow
|
- python-lxml # because pip installation is slow
|
||||||
# needed because server-tools is loaded in the dependency chain
|
|
||||||
- unixodbc-dev
|
|
||||||
- python-mysqldb
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" UNIT_TEST="0"
|
- VERSION="11.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" UNIT_TEST="0"
|
||||||
# - TRANSIFEX_USER='transbot@odoo-community.org'
|
# - TRANSIFEX_USER='transbot@odoo-community.org'
|
||||||
# - secure: "XLhGdCIh86zcqww9qBpnk8Xqsf1Pcgw9SKr7X0KYBHJofHj4Z6Kq/oVFjpZ1LSjadsaABKbwY7h4hvKEpxZwptCv+fNTOKYy7hXFLGYnDeNeWu4zA4LI7TA5uPvyZjZ+g2xc+9dzR/VbfRHNqjvmgiEidxxqLeOnNFZ5CHdOdCw="
|
# - secure: "XLhGdCIh86zcqww9qBpnk8Xqsf1Pcgw9SKr7X0KYBHJofHj4Z6Kq/oVFjpZ1LSjadsaABKbwY7h4hvKEpxZwptCv+fNTOKYy7hXFLGYnDeNeWu4zA4LI7TA5uPvyZjZ+g2xc+9dzR/VbfRHNqjvmgiEidxxqLeOnNFZ5CHdOdCw="
|
||||||
matrix:
|
matrix:
|
||||||
@@ -27,9 +24,6 @@ env:
|
|||||||
- TESTS="1" ODOO_REPO="odoo/odoo"
|
- TESTS="1" ODOO_REPO="odoo/odoo"
|
||||||
- TESTS="1" ODOO_REPO="OCA/OCB"
|
- TESTS="1" ODOO_REPO="OCA/OCB"
|
||||||
|
|
||||||
virtualenv:
|
|
||||||
system_site_packages: true
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools --depth=1
|
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools --depth=1
|
||||||
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
|
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
|
||||||
@@ -37,6 +31,10 @@ install:
|
|||||||
- git clone -b ${VERSION} https://github.com/OCA/web.git ${HOME}/dependencies/web --depth=1
|
- git clone -b ${VERSION} https://github.com/OCA/web.git ${HOME}/dependencies/web --depth=1
|
||||||
- git clone -b ${VERSION} https://github.com/OCA/partner-contact.git ${HOME}/dependencies/partner-contact --depth=1
|
- git clone -b ${VERSION} https://github.com/OCA/partner-contact.git ${HOME}/dependencies/partner-contact --depth=1
|
||||||
- git clone -b ${VERSION} https://github.com/OCA/account-payment.git ${HOME}/dependencies/account_payment_return --depth=1
|
- git clone -b ${VERSION} https://github.com/OCA/account-payment.git ${HOME}/dependencies/account_payment_return --depth=1
|
||||||
|
- git clone -b ${VERSION} https://github.com/OCA/connector.git ${HOME}/dependencies/connector --depth=1
|
||||||
|
- git clone -b ${VERSION} https://github.com/OCA/queue.git ${HOME}/dependencies/queue --depth=1
|
||||||
|
- pip install odoorpc
|
||||||
|
- pip install cachetools
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- travis_wait travis_run_tests
|
- travis_wait travis_run_tests
|
||||||
|
|||||||
@@ -13,33 +13,33 @@
|
|||||||
|
|
||||||
<!-- hotel_room_amenities_type -->
|
<!-- hotel_room_amenities_type -->
|
||||||
|
|
||||||
<record id="hotel_room_amenities_type_0" model="hotel.room.amenities.type">
|
<record id="hotel_amenitiy_type_0" model="hotel.amenity.type">
|
||||||
<field name="name">Beds</field>
|
<field name="name">Beds</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="hotel_room_amenities_type_1" model="hotel.room.amenities.type">
|
<record id="hotel_amenity_type_1" model="hotel.amenity.type">
|
||||||
<field name="name">Connectivity</field>
|
<field name="name">Connectivity</field>
|
||||||
</record>
|
</record>
|
||||||
<record id="hotel_room_amenities_type_2" model="hotel.room.amenities.type">
|
<record id="hotel_amenity_type_2" model="hotel.amenity.type">
|
||||||
<field name="name">Extra</field>
|
<field name="name">Extra</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- hotel_room_amenitues -->
|
<!-- hotel_room_amenitues -->
|
||||||
|
|
||||||
<record id="hotel_room_amenities_0" model="hotel.room.amenities">
|
<record id="hotel_amenity_0" model="hotel.amenity">
|
||||||
<field name="name">Twin Beds</field>
|
<field name="name">Twin Beds</field>
|
||||||
<field name="room_amenities_type_id" search="[('name', '=', 'Beds')]"/>
|
<field name="room_amenity_type_id" search="[('name', '=', 'Beds')]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="hotel_room_amenities_1" model="hotel.room.amenities">
|
<record id="hotel_amenity_1" model="hotel.amenity">
|
||||||
<field name="name">Double Beds</field>
|
<field name="name">Double Beds</field>
|
||||||
<field name="room_amenities_type_id" search="[('name', '=', 'Beds')]"/>
|
<field name="room_amenity_type_id" search="[('name', '=', 'Beds')]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="hotel_room_amenities_2" model="hotel.room.amenities">
|
<record id="hotel_amenity_2" model="hotel.amenity">
|
||||||
<field name="name">Extra Bed</field>
|
<field name="name">Extra Bed</field>
|
||||||
<field name="room_amenities_type_id" search="[('name', '=', 'Beds')]"/>
|
<field name="room_amenity_type_id" search="[('name', '=', 'Beds')]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="hotel_room_amenities_3" model="hotel.room.amenities">
|
<record id="hotel_amenity_3" model="hotel.amenity">
|
||||||
<field name="name">4G</field>
|
<field name="name">4G</field>
|
||||||
<field name="room_amenities_type_id" search="[('name', '=', 'Connectivity')]"/>
|
<field name="room_amenity_type_id" search="[('name', '=', 'Connectivity')]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
<field name="floor_id" search="[('name', '=', 'Second Floor')]"/>
|
<field name="floor_id" search="[('name', '=', 'Second Floor')]"/>
|
||||||
<field name="list_price">25.00</field>
|
<field name="list_price">25.00</field>
|
||||||
<field name="capacity">3</field>
|
<field name="capacity">3</field>
|
||||||
</record
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ class HotelReservation(models.Model):
|
|||||||
checkout = values.get('checkout')
|
checkout = values.get('checkout')
|
||||||
room_type = values.get('room_type_id')
|
room_type = values.get('room_type_id')
|
||||||
if checkin and checkout and room_type:
|
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
|
# Check room_chosen exist
|
||||||
res.update({
|
res.update({
|
||||||
'room_id': room_chosen.id
|
'room_id': room_chosen.id
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ class HotelRoom(models.Model):
|
|||||||
name = fields.Char('Room Name', required=True)
|
name = fields.Char('Room Name', required=True)
|
||||||
active = fields.Boolean('Active', default=True)
|
active = fields.Boolean('Active', default=True)
|
||||||
sequence = fields.Integer('Sequence', default=0)
|
sequence = fields.Integer('Sequence', default=0)
|
||||||
room_type_id = fields.Many2one('hotel.room.type', 'Hotel Room Type')
|
room_type_id = fields.Many2one('hotel.room.type', 'Hotel Room Type',
|
||||||
|
required=True,
|
||||||
|
ondelete='restrict')
|
||||||
floor_id = fields.Many2one('hotel.floor', 'Ubication',
|
floor_id = fields.Many2one('hotel.floor', 'Ubication',
|
||||||
help='At which floor the room is located.')
|
help='At which floor the room is located.')
|
||||||
max_adult = fields.Integer('Max Adult')
|
max_adult = fields.Integer('Max Adult')
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
# Copyright 2017 Alexandre Díaz
|
# Copyright 2017 Alexandre Díaz
|
||||||
# Copyright 2017 Dario Lodeiros
|
# Copyright 2017 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
class HotelRoomType(models.Model):
|
class HotelRoomType(models.Model):
|
||||||
""" Before creating a 'room type', you need to consider the following:
|
""" Before creating a 'room type', you need to consider the following:
|
||||||
@@ -11,7 +12,7 @@ class HotelRoomType(models.Model):
|
|||||||
_name = "hotel.room.type"
|
_name = "hotel.room.type"
|
||||||
_description = "Room Type"
|
_description = "Room Type"
|
||||||
_inherits = {'product.product': 'product_id'}
|
_inherits = {'product.product': 'product_id'}
|
||||||
|
|
||||||
# Relationship between models
|
# Relationship between models
|
||||||
product_id = fields.Many2one('product.product', 'Product Room Type',
|
product_id = fields.Many2one('product.product', 'Product Room Type',
|
||||||
required=True, delegate=True,
|
required=True, delegate=True,
|
||||||
@@ -64,8 +65,7 @@ class HotelRoomType(models.Model):
|
|||||||
return min(capacities) if any(capacities) else 0
|
return min(capacities) if any(capacities) else 0
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
# TODO Rename to check_availability_room_type
|
def check_availability_room_type(self, dfrom, dto,
|
||||||
def check_availability_room(self, dfrom, dto,
|
|
||||||
room_type_id=False, notthis=[]):
|
room_type_id=False, notthis=[]):
|
||||||
"""
|
"""
|
||||||
Check the avalability for an specific type of room
|
Check the avalability for an specific type of room
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class HotelRoomTypeAvailability(models.Model):
|
|||||||
record.avail = 0
|
record.avail = 0
|
||||||
else:
|
else:
|
||||||
room_type_obj = self.env['hotel.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(
|
||||||
record.date,
|
record.date,
|
||||||
record.date,
|
record.date,
|
||||||
room_type_id=record.room_type_id.id))
|
room_type_id=record.room_type_id.id))
|
||||||
|
|||||||
@@ -20,5 +20,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from . import test_reservation
|
#from . import test_reservation
|
||||||
from . import test_folio
|
#from . import test_folio
|
||||||
|
from . import test_hotel_room_type_model
|
||||||
|
from . import test_hotel_room_model
|
||||||
|
|||||||
@@ -21,21 +21,18 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from odoo import api, fields
|
from odoo import api, fields
|
||||||
from odoo.tests import common
|
from odoo.tests import common
|
||||||
from openerp.tools import (
|
from odoo.tools import (
|
||||||
DEFAULT_SERVER_DATE_FORMAT,
|
DEFAULT_SERVER_DATE_FORMAT,
|
||||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
from odoo.addons.mail.tests.common import TestMail
|
|
||||||
from odoo.addons.hotel import date_utils
|
|
||||||
import pytz
|
|
||||||
import logging
|
import logging
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# TestMail crea recursos utiles para nuestros test...
|
# TestMail crea recursos utiles para nuestros test...
|
||||||
# por ejemplo, usuarios con distintos tipos de nivel, etc...
|
# por ejemplo, usuarios con distintos tipos de nivel, etc...
|
||||||
class TestHotel(TestMail):
|
class TestHotel(common.SavepointCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _init_mock_hotel(cls):
|
def _init_mock_hotel(cls):
|
||||||
@@ -67,13 +64,13 @@ class TestHotel(TestMail):
|
|||||||
"Hotel Calendar can't create a new reservation!")
|
"Hotel Calendar can't create a new reservation!")
|
||||||
|
|
||||||
# Create Reservation Lines + Update Reservation Price
|
# Create Reservation Lines + Update Reservation Price
|
||||||
days_diff = date_utils.date_diff(checkin, checkout, hours=False)
|
# days_diff = date_utils.date_diff(checkin, checkout, hours=False)
|
||||||
res = reservation.sudo(creator).prepare_reservation_lines(
|
# res = reservation.sudo(creator).prepare_reservation_lines(
|
||||||
checkin.strftime(DEFAULT_SERVER_DATETIME_FORMAT), days_diff)
|
# checkin.strftime(DEFAULT_SERVER_DATETIME_FORMAT), days_diff)
|
||||||
reservation.sudo(creator).write({
|
# reservation.sudo(creator).write({
|
||||||
'reservation_lines': res['commands'],
|
# 'reservation_lines': res['commands'],
|
||||||
'price_unit': res['total_price'],
|
# 'price_unit': res['total_price'],
|
||||||
})
|
# })
|
||||||
|
|
||||||
return reservation
|
return reservation
|
||||||
|
|
||||||
@@ -83,169 +80,16 @@ class TestHotel(TestMail):
|
|||||||
|
|
||||||
cls._init_mock_hotel()
|
cls._init_mock_hotel()
|
||||||
|
|
||||||
# Restriction Plan
|
|
||||||
cls.restriction_1 = cls.env['hotel.room.type.restriction'].create({
|
|
||||||
'name': 'Restriction Test #1',
|
|
||||||
'active': True
|
|
||||||
})
|
|
||||||
|
|
||||||
# Pricelist
|
|
||||||
cls.pricelist_1 = cls.env['product.pricelist'].create({
|
|
||||||
'name': 'Pricelist Test #1',
|
|
||||||
})
|
|
||||||
|
|
||||||
# Minimal Hotel Configuration
|
|
||||||
cls.tz_hotel = 'Europe/Madrid'
|
|
||||||
cls.default_pricelist_id = cls.pricelist_1.id
|
|
||||||
cls.default_restriction_id = cls.restriction_1.id
|
|
||||||
cls.env['ir.values'].sudo().set_default('res.config.settings',
|
|
||||||
'tz_hotel', cls.tz_hotel)
|
|
||||||
cls.env['ir.values'].sudo().set_default('res.config.settings',
|
|
||||||
'default_pricelist_id',
|
|
||||||
cls.default_pricelist_id)
|
|
||||||
cls.env['ir.values'].sudo().set_default('res.config.settings',
|
|
||||||
'default_restriction_id',
|
|
||||||
cls.default_restriction_id)
|
|
||||||
|
|
||||||
# User Groups
|
|
||||||
user_group_hotel_manager = cls.env.ref('hotel.group_hotel_manager')
|
|
||||||
user_group_hotel_user = cls.env.ref('hotel.group_hotel_user')
|
|
||||||
user_group_employee = cls.env.ref('base.group_user')
|
|
||||||
user_group_public = cls.env.ref('base.group_public')
|
|
||||||
user_group_account_inv = cls.env.ref('account.group_account_invoice')
|
|
||||||
user_group_sale_manager = cls.env.ref('sales_team.group_sale_manager')
|
|
||||||
user_group_base_partner_manager = cls.env.ref(
|
|
||||||
'base.group_partner_manager')
|
|
||||||
|
|
||||||
# Create Test Users
|
|
||||||
Users = cls.env['res.users'].with_context({
|
|
||||||
'no_reset_password': True,
|
|
||||||
'mail_create_nosubscribe': True
|
|
||||||
})
|
|
||||||
cls.user_hotel_manager = Users.create({
|
|
||||||
'name': 'Jeff Hotel Manager',
|
|
||||||
'login': 'hoteljeff',
|
|
||||||
'email': 'mynameisjeff@example.com',
|
|
||||||
'signature': '--\nJeff',
|
|
||||||
'notify_email': 'always',
|
|
||||||
'groups_id': [(6, 0, [user_group_hotel_manager.id,
|
|
||||||
user_group_employee.id,
|
|
||||||
user_group_account_inv.id,
|
|
||||||
user_group_sale_manager.id,
|
|
||||||
user_group_base_partner_manager.id])]
|
|
||||||
})
|
|
||||||
cls.user_hotel_user = Users.create({
|
|
||||||
'name': 'Juancho Hotel User',
|
|
||||||
'login': 'juancho',
|
|
||||||
'email': 'juancho@example.com',
|
|
||||||
'signature': '--\nJuancho',
|
|
||||||
'notify_email': 'always',
|
|
||||||
'groups_id': [(6, 0, [user_group_hotel_user.id,
|
|
||||||
user_group_public.id])]
|
|
||||||
})
|
|
||||||
|
|
||||||
# Create Tests Records
|
# Create Tests Records
|
||||||
RoomTypes = cls.env['hotel.room.type']
|
cls.room_type_0 = cls.env.ref('hotel.hotel_room_type_0')
|
||||||
cls.hotel_room_type_simple = RoomTypes.create({
|
cls.room_type_1 = cls.env.ref('hotel.hotel_room_type_1')
|
||||||
'name': 'Simple',
|
cls.room_type_2 = cls.env.ref('hotel.hotel_room_type_2')
|
||||||
'code_type': 'TSMP',
|
cls.room_type_3 = cls.env.ref('hotel.hotel_room_type_3')
|
||||||
})
|
|
||||||
cls.hotel_room_type_double = RoomTypes.create({
|
|
||||||
'name': 'Double',
|
|
||||||
'code_type': 'TDBL',
|
|
||||||
})
|
|
||||||
|
|
||||||
VRooms = cls.env['hotel.virtual.room']
|
cls.room_0 = cls.env.ref('hotel.hotel_room_0')
|
||||||
cls.hotel_room_type_budget = VRooms.create({
|
cls.room_1 = cls.env.ref('hotel.hotel_room_1')
|
||||||
'name': 'Budget Room',
|
cls.room_2 = cls.env.ref('hotel.hotel_room_2')
|
||||||
'virtual_code': '001',
|
cls.room_3 = cls.env.ref('hotel.hotel_room_3')
|
||||||
'list_price': 50,
|
cls.room_4 = cls.env.ref('hotel.hotel_room_4')
|
||||||
})
|
cls.room_5 = cls.env.ref('hotel.hotel_room_5')
|
||||||
cls.hotel_room_type_special = VRooms.create({
|
cls.room_6 = cls.env.ref('hotel.hotel_room_6')
|
||||||
'name': 'Special Room',
|
|
||||||
'virtual_code': '002',
|
|
||||||
'list_price': 150,
|
|
||||||
})
|
|
||||||
|
|
||||||
Rooms = cls.env['hotel.room']
|
|
||||||
cls.hotel_room_simple_100 = Rooms.create({
|
|
||||||
'name': '100',
|
|
||||||
'sale_price_type': 'room_type',
|
|
||||||
'price_room_type': cls.hotel_room_type_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': 'room_type',
|
|
||||||
'price_room_type': cls.hotel_room_type_budget.id,
|
|
||||||
'categ_id': cls.hotel_room_type_simple.cat_id.id,
|
|
||||||
'capacity': 1,
|
|
||||||
'sequence': 1,
|
|
||||||
})
|
|
||||||
cls.hotel_room_double_200 = Rooms.create({
|
|
||||||
'name': '200',
|
|
||||||
'sale_price_type': 'room_type',
|
|
||||||
'price_room_type': cls.hotel_room_type_special.id,
|
|
||||||
'categ_id': cls.hotel_room_type_double.cat_id.id,
|
|
||||||
'capacity': 2,
|
|
||||||
})
|
|
||||||
|
|
||||||
cls.hotel_room_type_budget.write({
|
|
||||||
'room_ids': [(6, False, [cls.hotel_room_simple_100.id,
|
|
||||||
cls.hotel_room_simple_101.id])],
|
|
||||||
})
|
|
||||||
cls.hotel_room_type_special.write({
|
|
||||||
'room_ids': [(6, False, [cls.hotel_room_double_200.id])],
|
|
||||||
})
|
|
||||||
|
|
||||||
# Create a week of fresh data
|
|
||||||
now_utc_dt = date_utils.now()
|
|
||||||
cls.avails_tmp = {
|
|
||||||
cls.hotel_room_type_budget.id: (1, 2, 2, 1, 1, 2, 2),
|
|
||||||
cls.hotel_room_type_special.id: (1, 1, 1, 1, 1, 1, 1),
|
|
||||||
}
|
|
||||||
cls.prices_tmp = {
|
|
||||||
cls.hotel_room_type_budget.id: (10.0, 80.0, 80.0, 95.0, 90.0, 80.0,
|
|
||||||
20.0),
|
|
||||||
cls.hotel_room_type_special.id: (5.0, 15.0, 15.0, 35.0, 35.0, 10.0,
|
|
||||||
10.0),
|
|
||||||
}
|
|
||||||
cls.restrictions_min_stay_tmp = {
|
|
||||||
cls.hotel_room_type_budget.id: (0, 1, 2, 1, 1, 0, 0),
|
|
||||||
cls.hotel_room_type_special.id: (3, 1, 0, 2, 0, 1, 4),
|
|
||||||
}
|
|
||||||
budget_product_id = cls.hotel_room_type_budget.product_id
|
|
||||||
special_product_id = cls.hotel_room_type_special.product_id
|
|
||||||
product_tmpl_ids = {
|
|
||||||
cls.hotel_room_type_budget.id: budget_product_id.product_tmpl_id.id,
|
|
||||||
cls.hotel_room_type_special.id: special_product_id.product_tmpl_id.id,
|
|
||||||
}
|
|
||||||
room_type_avail_obj = cls.env['hotel.room.type.availability']
|
|
||||||
room_type_rest_item_obj = cls.env['hotel.room.type.restriction.item']
|
|
||||||
pricelist_item_obj = cls.env['product.pricelist.item']
|
|
||||||
for k_vr, v_vr in cls.avails_tmp.iteritems():
|
|
||||||
for i in range(0, len(v_vr)):
|
|
||||||
ndate = now_utc_dt + timedelta(days=i)
|
|
||||||
room_type_avail_obj.create({
|
|
||||||
'room_type_id': k_vr,
|
|
||||||
'avail': v_vr[i],
|
|
||||||
'date': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
|
||||||
})
|
|
||||||
room_type_rest_item_obj.create({
|
|
||||||
'room_type_id': k_vr,
|
|
||||||
'restriction_id': cls.default_restriction_id,
|
|
||||||
'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
|
||||||
'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
|
||||||
'applied_on': '0_room_type',
|
|
||||||
'min_stay': cls.restrictions_min_stay_tmp[k_vr][i],
|
|
||||||
})
|
|
||||||
pricelist_item_obj.create({
|
|
||||||
'pricelist_id': cls.default_pricelist_id,
|
|
||||||
'date_start': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
|
||||||
'date_end': ndate.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
|
||||||
'compute_price': 'fixed',
|
|
||||||
'applied_on': '1_product',
|
|
||||||
'product_tmpl_id': product_tmpl_ids[k_vr],
|
|
||||||
'fixed_price': cls.prices_tmp[k_vr][i],
|
|
||||||
})
|
|
||||||
|
|||||||
34
hotel/tests/test_hotel_room_model.py
Normal file
34
hotel/tests/test_hotel_room_model.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -*- 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 .common import TestHotel
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class TestHotelRoom(TestHotel):
|
||||||
|
|
||||||
|
def test_check_capacity(self):
|
||||||
|
# TODO Do the test using different users
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
self.room_0.sudo().write({
|
||||||
|
'capacity': 0
|
||||||
|
})
|
||||||
34
hotel/tests/test_hotel_room_type_model.py
Normal file
34
hotel/tests/test_hotel_room_type_model.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# -*- 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 .common import TestHotel
|
||||||
|
from psycopg2 import IntegrityError
|
||||||
|
|
||||||
|
|
||||||
|
class TestHotelRoomType(TestHotel):
|
||||||
|
|
||||||
|
def test_code_type_unique(self):
|
||||||
|
#TODO: use sudo users hotel
|
||||||
|
with self.assertRaises(IntegrityError):
|
||||||
|
self.room_type_0.sudo().write({
|
||||||
|
'code_type': self.room_type_1.code_type
|
||||||
|
})
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="date" required="1"/>
|
<field name="date" required="1"/>
|
||||||
<field name="avail"/>
|
<field name="avail"/>
|
||||||
<field name="no_ota"/>
|
|
||||||
<field name="booked"/>
|
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
<div class="oe_chatter">
|
<div class="oe_chatter">
|
||||||
@@ -37,8 +35,6 @@
|
|||||||
<field name="room_type_id" required="1"/>
|
<field name="room_type_id" required="1"/>
|
||||||
<field name="date" required="1"/>
|
<field name="date" required="1"/>
|
||||||
<field name="avail"/>
|
<field name="avail"/>
|
||||||
<field name="no_ota"/>
|
|
||||||
<field name="booked"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class DuplicateReservationWizard(models.TransientModel):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
# Check Input
|
# Check Input
|
||||||
avails = hotel_room_type_obj.check_availability_room(
|
avails = hotel_room_type_obj.check_availability_room_type(
|
||||||
reservation_id.checkin,
|
reservation_id.checkin,
|
||||||
reservation_id.checkout,
|
reservation_id.checkout,
|
||||||
room_type_id=reservation_id.room_type_id.id)
|
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)
|
There are no '%d' free rooms") % self.num)
|
||||||
|
|
||||||
for i in range(0, 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.checkin,
|
||||||
reservation_id.checkout,
|
reservation_id.checkout,
|
||||||
room_type_id=reservation_id.room_type_id.id)
|
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']
|
hotel_room_type_obj = self.env['hotel.room.type']
|
||||||
vals = {}
|
vals = {}
|
||||||
if record.change_avail:
|
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),
|
||||||
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
ndate.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||||
room_type_id=room_type.id))
|
room_type_id=room_type.id))
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ class HotelRoomTypeWizards(models.TransientModel):
|
|||||||
avail_restrictions = self.env['hotel.room.type.availability'].search([
|
avail_restrictions = self.env['hotel.room.type.availability'].search([
|
||||||
('room_type_id', '=', res.room_type_id.id)
|
('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.checkin,
|
||||||
res.checkout,
|
res.checkout,
|
||||||
res.room_type_id.id))
|
res.room_type_id.id))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class HotelCalendarManagement(models.TransientModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def _get_availability_values(self, avail, room_type):
|
def _get_availability_values(self, avail, room_type):
|
||||||
room_type_obj = self.env['hotel.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))
|
avail['date'], avail['date'], room_type_id=room_type.id))
|
||||||
ravail = min(cavail, room_type.total_rooms_count, int(avail['avail']))
|
ravail = min(cavail, room_type.total_rooms_count, int(avail['avail']))
|
||||||
vals = {
|
vals = {
|
||||||
@@ -251,7 +251,7 @@ class HotelCalendarManagement(models.TransientModel):
|
|||||||
json_data.setdefault(room_type.id, []).append({
|
json_data.setdefault(room_type.id, []).append({
|
||||||
'date': cur_date_str,
|
'date': cur_date_str,
|
||||||
'num': len(
|
'num': len(
|
||||||
room_type_obj.check_availability_room(
|
room_type_obj.check_availability_room_type(
|
||||||
cur_date_str,
|
cur_date_str,
|
||||||
cur_date_str,
|
cur_date_str,
|
||||||
room_type_id=room_type.id)),
|
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']),
|
internal_message="Invalid reservation total price! %.2f != %.2f" % (vals['price_unit'], book['amount']),
|
||||||
channel_object_id=book['reservation_code'])
|
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,
|
checkin_str,
|
||||||
checkout_str,
|
checkout_str,
|
||||||
room_type_id=room_type.odoo_id.id,
|
room_type_id=room_type.odoo_id.id,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class HotelRoomTypeAvailability(models.Model):
|
|||||||
room_type_obj = self.env['hotel.room.type']
|
room_type_obj = self.env['hotel.room.type']
|
||||||
issue_obj = self.env['hotel.channel.connector.issue']
|
issue_obj = self.env['hotel.channel.connector.issue']
|
||||||
for record in self:
|
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,
|
||||||
record.date,
|
record.date,
|
||||||
room_type_id=record.room_type_id.id))
|
room_type_id=record.room_type_id.id))
|
||||||
@@ -143,7 +143,7 @@ class HotelRoomTypeAvailability(models.Model):
|
|||||||
for i in range(0, date_diff):
|
for i in range(0, date_diff):
|
||||||
ndate_dt = date_start + timedelta(days=i)
|
ndate_dt = date_start + timedelta(days=i)
|
||||||
ndate_str = ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
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,
|
||||||
ndate_str,
|
ndate_str,
|
||||||
room_type_id=room_type.id))
|
room_type_id=room_type.id))
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
# Copyright 2018 Dario Lodeiros
|
# Copyright 2018 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import wdb
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
@@ -18,12 +17,12 @@ class HotelRoomType(models.Model):
|
|||||||
Check availability for all or specific room types between dates
|
Check availability for all or specific room types between dates
|
||||||
@return: A list of `ids` with free rooms
|
@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
|
return free_rooms.ids
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get_room_type_availability(self, dfrom, dto, room_type_id):
|
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([
|
availability_real = self.env['hotel.room'].search_count([
|
||||||
('id', 'in', free_rooms.ids),
|
('id', 'in', free_rooms.ids),
|
||||||
('room_type_id', '=', room_type_id),
|
('room_type_id', '=', room_type_id),
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
# Copyright 2018 Dario Lodeiros
|
# Copyright 2018 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import wdb
|
|
||||||
import logging
|
import logging
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import odoorpc.odoo
|
import odoorpc.odoo
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
# Copyright 2018 Dario Lodeiros
|
# Copyright 2018 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import wdb
|
|
||||||
import logging
|
import logging
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
# Copyright 2018 Dario Lodeiros
|
# Copyright 2018 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
import wdb
|
|
||||||
import logging
|
import logging
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import odoorpc.odoo
|
import odoorpc.odoo
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# Copyright 2018 Alexandre Díaz
|
# Copyright 2018 Alexandre Díaz
|
||||||
# Copyright 2018 Dario Lodeiros
|
# Copyright 2018 Dario Lodeiros
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import wdb
|
|
||||||
import logging
|
import logging
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import odoorpc.odoo
|
import odoorpc.odoo
|
||||||
|
|||||||
Reference in New Issue
Block a user