mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Code review (#62)
* [REF] pms: refactor amenity type * [REF] pms: refactor amenity * [REF]Refactor amenity views and demo data * [WIP] master model 2nd day * [WIP] Master model refactor * [WIP] Refactor in tests * [WIP] Add mandatory sequence in pms_property at tests and fix create in folio, reservation and checkin * [WIP] Test refactor * [WIP]Refactor pms_room, pms_room_clousure_reason and pms_room_type * [WIP]review of guidelines in master models * [WIP]test refactor * [WIP]review guidelines in master models 2 * [WIP] fixed fields in pms_l10n_es * [WIP]Refactor product_product, product_template, res_company, res_partner and res_user * [IMP] Add common.py for tests * [WIP] Refactor fields in pms.folio and pms.reservation * [WIP] Review guidelines in pms.reservation, pms.reservation.line and rename availability models * [WIP] Rename availability models * [WIP] Refactor availability models * [WIP] Refactor availity models 2 * [WIP] Pms: add sequences creation in pms_property create * [WIP] Fix sequence creation in pmp.property * [REF] Refactor fields in res_partner and rename date_overnight * [REF] Refactoring master models tests * [FIX] Fix sequence create in pms.reservation * [REF] Refactor helps in master and availability models * [IMP] Extend test coverage in test_pms_reservation * [REF] Refactor fields in pms_reservation * [REF] Refactor fields in pms_reservation 2 * [REF] Refactor fields in service flow * [REF] Refactor pms_reservation * [REF] Refactor pms_reservation 2 * [REF] draft button removed from view * [REF] change no_show to arrival_delayed in field state of pms_reservation * [REF] Add compute_preferred_room_id in pms_reservation * [REF] Fix cache problem in test_reservation_action_checkout Co-authored-by: braisab <braisterbutalino@gmail.com> Co-authored-by: Sara Lago <saralago126@gmail.com> Co-authored-by: Brais Abeijón <>
This commit is contained in:
@@ -25,7 +25,7 @@ from . import test_pms_pricelist_priority
|
||||
from . import test_pms_checkin_partner
|
||||
from . import test_pms_sale_channel
|
||||
from . import test_pms_folio
|
||||
from . import test_pms_room_type_availability_rules
|
||||
from . import test_pms_availability_plan_rules
|
||||
from . import test_pms_room_type
|
||||
from . import test_pms_room_type_class
|
||||
from . import test_pms_wizard_massive_changes
|
||||
|
||||
@@ -1,63 +1,29 @@
|
||||
##############################################################################
|
||||
#
|
||||
# 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 logging
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestHotel(common.SavepointCase):
|
||||
@classmethod
|
||||
def _init_mock_hotel(cls):
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestHotel, cls).setUpClass()
|
||||
|
||||
cls._init_mock_hotel()
|
||||
|
||||
# Create Tests Records
|
||||
cls.main_hotel_property = cls.env.ref("pms.main_pms_property")
|
||||
cls.demo_hotel_property = cls.env.ref("pms.demo_pms_property")
|
||||
|
||||
cls.room_type_0 = cls.env.ref("pms.pms_room_type_0")
|
||||
cls.room_type_1 = cls.env.ref("pms.pms_room_type_1")
|
||||
cls.room_type_2 = cls.env.ref("pms.pms_room_type_2")
|
||||
cls.room_type_3 = cls.env.ref("pms.pms_room_type_3")
|
||||
|
||||
cls.demo_room_type_0 = cls.env.ref("pms.demo_pms_room_type_0")
|
||||
cls.demo_room_type_1 = cls.env.ref("pms.demo_pms_room_type_1")
|
||||
|
||||
cls.room_0 = cls.env.ref("pms.pms_room_0")
|
||||
cls.room_1 = cls.env.ref("pms.pms_room_1")
|
||||
cls.room_2 = cls.env.ref("pms.pms_room_2")
|
||||
cls.room_3 = cls.env.ref("pms.pms_room_3")
|
||||
cls.room_4 = cls.env.ref("pms.pms_room_4")
|
||||
cls.room_5 = cls.env.ref("pms.pms_room_5")
|
||||
cls.room_6 = cls.env.ref("pms.pms_room_6")
|
||||
|
||||
cls.list0 = cls.env.ref("product.list0")
|
||||
cls.list1 = cls.env["product.pricelist"].create(
|
||||
{"name": "Test Pricelist", "pricelist_type": ""}
|
||||
class TestPms(common.SavepointCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.pricelist1 = self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "Pricelist 1",
|
||||
}
|
||||
)
|
||||
self.company1 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Company 1",
|
||||
}
|
||||
)
|
||||
self.pms_property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property 1",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
self.room_type_class1 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room Type Class 1",
|
||||
"code_class": "RTC1",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,98 +1,183 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from .common import TestPms
|
||||
|
||||
|
||||
class TestPmsAmenity(TestHotel):
|
||||
def create_common_scenario(self):
|
||||
# create company and properties
|
||||
self.company1 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Pms_Company_Test",
|
||||
}
|
||||
)
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property_test1",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
self.property2 = self.env["pms.property"].create(
|
||||
class TestPmsAmenity(TestPms):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
# Create two properties
|
||||
# +-----------+-----------+
|
||||
# | Properties |
|
||||
# +-----------+-----------+
|
||||
# | Property2 - Property3 |
|
||||
# +-----------+-----------+
|
||||
|
||||
self.pms_property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property_test2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.property3 = self.env["pms.property"].create(
|
||||
self.pms_property3 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property_test3",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_property_not_allowed(self):
|
||||
# Creation of a Amenity with Properties incompatible with it Amenity Type
|
||||
|
||||
# +-----------------------------------+-----------------------------------+
|
||||
# | Amenity Type (TestAmenityType1) | Amenity (TestAmenity1) |
|
||||
# +-----------------------------------+-----------------------------------+
|
||||
# | Property1 - Property2 | Property1 - Property2 - Property3 |
|
||||
# +-----------------------------------+-----------------------------------+
|
||||
|
||||
# ARRANGE
|
||||
name = "amenityTest1"
|
||||
name2 = "amenity"
|
||||
self.create_common_scenario()
|
||||
AmenityType = self.env["pms.amenity.type"]
|
||||
Amenity = self.env["pms.amenity"]
|
||||
# ACT
|
||||
A1 = AmenityType.create(
|
||||
amenity_type1 = AmenityType.create(
|
||||
{
|
||||
"name": name,
|
||||
"name": "TestAmenityType1",
|
||||
"pms_property_ids": [
|
||||
(4, self.property1.id),
|
||||
(4, self.property2.id),
|
||||
(4, self.pms_property1.id),
|
||||
(4, self.pms_property2.id),
|
||||
],
|
||||
}
|
||||
)
|
||||
# ASSERT
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||
Amenity.create(
|
||||
{
|
||||
"name": name2,
|
||||
"room_amenity_type_id": A1.id,
|
||||
"name": "TestAmenity1",
|
||||
"pms_amenity_type_id": amenity_type1.id,
|
||||
"pms_property_ids": [
|
||||
(4, self.property1.id),
|
||||
(4, self.property2.id),
|
||||
(4, self.property3.id),
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[
|
||||
self.pms_property1.id,
|
||||
self.pms_property2.id,
|
||||
self.pms_property3.id,
|
||||
],
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_allowed_property_ids(self):
|
||||
def test_property_allowed(self):
|
||||
# Creation of a Amenity with Properties compatible with it Amenity Type
|
||||
# Check Properties of Amenity are in Properties of Amenity Type
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# | Amenity Type (TestAmenityType1) | Amenity (TestAmenity1) |
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# | Property1 - Property2 - Property3 | Property1 - Property2 - Property3 |
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
|
||||
# ARRANGE
|
||||
name = "amenityTest1"
|
||||
name2 = "amenity"
|
||||
self.create_common_scenario()
|
||||
AmenityType = self.env["pms.amenity.type"]
|
||||
Amenity = self.env["pms.amenity"]
|
||||
# ACT
|
||||
AT1 = AmenityType.create(
|
||||
amenity_type1 = AmenityType.create(
|
||||
{
|
||||
"name": name,
|
||||
"name": "TestAmenityType1",
|
||||
"pms_property_ids": [
|
||||
(4, self.property1.id),
|
||||
(4, self.property2.id),
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[
|
||||
self.pms_property1.id,
|
||||
self.pms_property2.id,
|
||||
self.pms_property3.id,
|
||||
],
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
A2 = Amenity.create(
|
||||
# ACT
|
||||
amenity1 = Amenity.create(
|
||||
{
|
||||
"name": name2,
|
||||
"room_amenity_type_id": AT1.id,
|
||||
"name": "TestAmenity1",
|
||||
"pms_amenity_type_id": amenity_type1.id,
|
||||
"pms_property_ids": [
|
||||
(4, self.property1.id),
|
||||
(4, self.property2.id),
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[
|
||||
self.pms_property1.id,
|
||||
self.pms_property2.id,
|
||||
self.pms_property3.id,
|
||||
],
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
amenity1.pms_property_ids.ids,
|
||||
amenity_type1.pms_property_ids.ids,
|
||||
"Properties not allowed in amenity type",
|
||||
)
|
||||
|
||||
def test_change_amenity_property(self):
|
||||
# Creation of a Amenity with Properties compatible with it Amenity Type
|
||||
# Delete a Property in Amenity Type, check Validation Error when do that
|
||||
# 1st scenario:
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# | Amenity Type (TestAmenityType1) | Amenity (TestAmenity1) |
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# | Property1 - Property2 - Property3 | Property1 - Property2 - Property3 |
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# 2nd scenario(Error):
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# | Amenity Type (TestAmenityType1) | Amenity (TestAmenity1) |
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
# | Property1 - Property2 | Property1 - Property2 - Property3 |
|
||||
# +----------------------------------------+-----------------------------------+
|
||||
|
||||
# ARRANGE
|
||||
AmenityType = self.env["pms.amenity.type"]
|
||||
Amenity = self.env["pms.amenity"]
|
||||
amenity_type1 = AmenityType.create(
|
||||
{
|
||||
"name": "TestAmenityType1",
|
||||
"pms_property_ids": [
|
||||
(4, self.pms_property1.id),
|
||||
(4, self.pms_property2.id),
|
||||
(4, self.pms_property3.id),
|
||||
],
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
Amenity.create(
|
||||
{
|
||||
"name": "TestAmenity1",
|
||||
"pms_amenity_type_id": amenity_type1.id,
|
||||
"pms_property_ids": [
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[
|
||||
self.pms_property1.id,
|
||||
self.pms_property2.id,
|
||||
self.pms_property3.id,
|
||||
],
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
A2.allowed_property_ids, AT1.pms_property_ids, "Properties doesnt much"
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
amenity_type1.pms_property_ids = [
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[self.pms_property1.id, self.pms_property2.id],
|
||||
)
|
||||
]
|
||||
amenity_type1.flush()
|
||||
|
||||
@@ -4,12 +4,11 @@ from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
@freeze_time("1980-01-01")
|
||||
class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
class TestPmsRoomTypeAvailabilityRules(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# product.pricelist
|
||||
self.test_pricelist1 = self.env["product.pricelist"].create(
|
||||
@@ -22,21 +21,47 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"name": "test pricelist 2",
|
||||
}
|
||||
)
|
||||
# pms.room.type.availability.plan
|
||||
self.test_room_type_availability1 = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create(
|
||||
# pms.availability.plan
|
||||
self.test_room_type_availability1 = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
}
|
||||
)
|
||||
# SEQUENCES
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
# pms.property
|
||||
self.test_property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist1.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
# pms.room.type.class
|
||||
@@ -49,7 +74,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
"name": "Single Test",
|
||||
"code_type": "SNG_Test",
|
||||
"default_code": "SNG_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -60,7 +85,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
(4, self.test_property.id),
|
||||
],
|
||||
"name": "Double Test",
|
||||
"code_type": "DBL_Test",
|
||||
"default_code": "DBL_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -129,6 +154,9 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"name": "Property 1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist2.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.test_property2 = self.env["pms.property"].create(
|
||||
@@ -136,6 +164,9 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"name": "Property 2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist2.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.test_property3 = self.env["pms.property"].create(
|
||||
@@ -143,11 +174,12 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"name": "Property 3",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist2.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.availability_multiproperty = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create(
|
||||
self.availability_multiproperty = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
@@ -172,7 +204,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
)
|
||||
|
||||
# ACT
|
||||
result = self.env["pms.room.type.availability.plan"].rooms_available(
|
||||
result = self.env["pms.availability.plan"].rooms_available(
|
||||
checkin=checkin,
|
||||
checkout=checkout,
|
||||
)
|
||||
@@ -206,7 +238,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
)
|
||||
|
||||
# ACT
|
||||
result = self.env["pms.room.type.availability.plan"].rooms_available(
|
||||
result = self.env["pms.availability.plan"].rooms_available(
|
||||
checkin=checkin,
|
||||
checkout=checkout,
|
||||
current_lines=test_reservation.reservation_line_ids.ids,
|
||||
@@ -234,7 +266,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
)
|
||||
|
||||
# ACT
|
||||
result = self.env["pms.room.type.availability.plan"].rooms_available(
|
||||
result = self.env["pms.availability.plan"].rooms_available(
|
||||
checkin=fields.date.today(),
|
||||
checkout=(fields.datetime.today() + datetime.timedelta(days=4)).date(),
|
||||
room_type_id=self.test_room_type_double.id,
|
||||
@@ -258,7 +290,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
self.test_room_type_availability_rule1 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
@@ -269,7 +301,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
result = self.env["pms.room.type.availability.plan"].rooms_available(
|
||||
result = self.env["pms.availability.plan"].rooms_available(
|
||||
checkin=fields.date.today(),
|
||||
checkout=(fields.datetime.today() + datetime.timedelta(days=4)).date(),
|
||||
# room_type_id=False, # <- (2/2)
|
||||
@@ -293,7 +325,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
self.create_common_scenario()
|
||||
|
||||
self.test_room_type_availability_rule1 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
@@ -411,7 +443,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
# ACT
|
||||
self.test_room_type_availability_rule1.write(test_case)
|
||||
|
||||
result = self.env["pms.room.type.availability.plan"].rooms_available(
|
||||
result = self.env["pms.availability.plan"].rooms_available(
|
||||
checkin=checkin,
|
||||
checkout=checkout,
|
||||
room_type_id=self.test_room_type_double.id,
|
||||
@@ -435,7 +467,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
self.test_room_type_availability_rule1 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
@@ -475,7 +507,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
self.test_room_type_availability_rule1 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
@@ -541,7 +573,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
self.create_common_scenario()
|
||||
|
||||
self.test_room_type_availability_rule1 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
@@ -595,7 +627,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
"name": "test pricelist 2",
|
||||
}
|
||||
)
|
||||
rule = self.env["pms.room.type.availability.rule"].create(
|
||||
rule = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
@@ -641,7 +673,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
(4, self.test_property2.id),
|
||||
],
|
||||
"name": "Special Room Test",
|
||||
"code_type": "SP_Test",
|
||||
"default_code": "SP_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -663,7 +695,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
}
|
||||
)
|
||||
self.test_room_type_availability_rule1 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.availability_multiproperty.id,
|
||||
@@ -674,7 +706,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
}
|
||||
)
|
||||
self.test_room_type_availability_rule2 = self.env[
|
||||
"pms.room.type.availability.rule"
|
||||
"pms.availability.plan.rule"
|
||||
].create(
|
||||
{
|
||||
"availability_plan_id": self.availability_multiproperty.id,
|
||||
@@ -695,9 +727,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
for p in properties:
|
||||
with self.subTest(k=p):
|
||||
# ACT
|
||||
rooms_avail = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].rooms_available(
|
||||
rooms_avail = self.env["pms.availability.plan"].rooms_available(
|
||||
checkin=fields.date.today(),
|
||||
checkout=(
|
||||
fields.datetime.today() + datetime.timedelta(days=2)
|
||||
@@ -725,12 +755,12 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
(4, self.test_property3.id),
|
||||
],
|
||||
"name": "Special Room Test",
|
||||
"code_type": "SP_Test",
|
||||
"default_code": "SP_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
self.availability_example = self.env["pms.room.type.availability.plan"].create(
|
||||
self.availability_example = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
@@ -740,7 +770,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
],
|
||||
}
|
||||
)
|
||||
self.availability_rule1 = self.env["pms.room.type.availability.rule"].create(
|
||||
self.availability_rule1 = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"availability_plan_id": self.availability_example.id,
|
||||
"room_type_id": self.test_room_type_special.id,
|
||||
@@ -790,12 +820,12 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
(4, self.test_property3.id),
|
||||
],
|
||||
"name": "Special Room Test",
|
||||
"code_type": "SP_Test",
|
||||
"default_code": "SP_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
self.availability_example = self.env["pms.room.type.availability.plan"].create(
|
||||
self.availability_example = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
@@ -805,7 +835,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
|
||||
],
|
||||
}
|
||||
)
|
||||
self.availability_rule1 = self.env["pms.room.type.availability.rule"].create(
|
||||
self.availability_rule1 = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"availability_plan_id": self.availability_example.id,
|
||||
"room_type_id": self.test_room_type_special.id,
|
||||
@@ -1,20 +1,46 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsBoardService(TestHotel):
|
||||
class TestPmsBoardService(common.SavepointCase):
|
||||
def test_property_integrity(self):
|
||||
self.company1 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Pms_Company_Test",
|
||||
}
|
||||
)
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property_test1",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.property2 = self.env["pms.property"].create(
|
||||
@@ -22,6 +48,9 @@ class TestPmsBoardService(TestHotel):
|
||||
"name": "Pms_property_test2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.product = self.env["product.product"].create(
|
||||
|
||||
@@ -1,18 +1,45 @@
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsBoardServiceRoomType(TestHotel):
|
||||
class TestPmsBoardServiceRoomType(common.SavepointCase):
|
||||
def _create_common_scenario(self):
|
||||
self.company1 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Pms_Company_Test",
|
||||
}
|
||||
)
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property_test1",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.property2 = self.env["pms.property"].create(
|
||||
@@ -20,6 +47,9 @@ class TestPmsBoardServiceRoomType(TestHotel):
|
||||
"name": "Pms_property_test2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.board_service = self.env["pms.board.service"].create(
|
||||
@@ -33,7 +63,7 @@ class TestPmsBoardServiceRoomType(TestHotel):
|
||||
self.room_type = self.env["pms.room.type"].create(
|
||||
{
|
||||
"name": "Room Type",
|
||||
"code_type": "Type1",
|
||||
"default_code": "Type1",
|
||||
"class_id": self.room_type_class.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,20 +1,46 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsBoardServiceRoomTypeLine(TestHotel):
|
||||
class TestPmsBoardServiceRoomTypeLine(common.SavepointCase):
|
||||
def test_check_product_property_integrity(self):
|
||||
self.company1 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Pms_Company_Test",
|
||||
}
|
||||
)
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.company1.id,
|
||||
}
|
||||
)
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property_test1",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.property2 = self.env["pms.property"].create(
|
||||
@@ -22,6 +48,9 @@ class TestPmsBoardServiceRoomTypeLine(TestHotel):
|
||||
"name": "Pms_property_test2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.board_service = self.env["pms.board.service"].create(
|
||||
@@ -39,7 +68,7 @@ class TestPmsBoardServiceRoomTypeLine(TestHotel):
|
||||
self.room_type = self.env["pms.room.type"].create(
|
||||
{
|
||||
"name": "Room Type",
|
||||
"code_type": "Type1",
|
||||
"default_code": "Type1",
|
||||
"class_id": self.room_type_class.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -4,14 +4,13 @@ from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@freeze_time("2012-01-14")
|
||||
class TestPmsCheckinPartner(TestHotel):
|
||||
class TestPmsCheckinPartner(common.SavepointCase):
|
||||
@classmethod
|
||||
def arrange_single_checkin(cls):
|
||||
# Arrange for one checkin on one reservation
|
||||
@@ -336,7 +335,7 @@ class TestPmsCheckinPartner(TestHotel):
|
||||
"Fail the checkins data ratio on reservation",
|
||||
)
|
||||
|
||||
def test_auto_no_show(self):
|
||||
def test_auto_arrival_delayed(self):
|
||||
|
||||
# ARRANGE
|
||||
self.arrange_folio_reservations()
|
||||
@@ -345,21 +344,21 @@ class TestPmsCheckinPartner(TestHotel):
|
||||
# ACTION
|
||||
freezer = freeze_time("2012-01-15 10:00:00")
|
||||
freezer.start()
|
||||
PmsReservation.auto_no_show()
|
||||
PmsReservation.auto_arrival_delayed()
|
||||
|
||||
no_show_reservations = self.folio_1.reservation_ids.filtered(
|
||||
lambda r: r.state == "no_show"
|
||||
arrival_delayed_reservations = self.folio_1.reservation_ids.filtered(
|
||||
lambda r: r.state == "arrival_delayed"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
len(no_show_reservations),
|
||||
len(arrival_delayed_reservations),
|
||||
3,
|
||||
"Reservations not set like No Show",
|
||||
)
|
||||
freezer.stop()
|
||||
|
||||
def test_auto_no_checkout(self):
|
||||
def test_auto_departure_delayed(self):
|
||||
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
@@ -369,14 +368,14 @@ class TestPmsCheckinPartner(TestHotel):
|
||||
# ACTION
|
||||
freezer = freeze_time("2012-01-17 12:00:00")
|
||||
freezer.start()
|
||||
PmsReservation.auto_no_checkout()
|
||||
PmsReservation.auto_departure_delayed()
|
||||
|
||||
freezer.stop()
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
self.reservation_1.state,
|
||||
"no_checkout",
|
||||
"Reservations not set like No checkout",
|
||||
"departure_delayed",
|
||||
"Reservations not set like Departure delayed",
|
||||
)
|
||||
|
||||
def test_not_valid_emails(self):
|
||||
|
||||
@@ -4,25 +4,51 @@ from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
freeze_time("2000-02-02")
|
||||
|
||||
|
||||
class TestPmsFolio(TestHotel):
|
||||
class TestPmsFolio(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# create a room type availability
|
||||
self.room_type_availability = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create({"name": "Availability plan for TEST"})
|
||||
|
||||
self.room_type_availability = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability plan for TEST"}
|
||||
)
|
||||
# sequences
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
# create a property
|
||||
self.property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -36,7 +62,7 @@ class TestPmsFolio(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.property.id],
|
||||
"name": "Double Test",
|
||||
"code_type": "DBL_Test",
|
||||
"default_code": "DBL_Test",
|
||||
"class_id": self.room_type_class.id,
|
||||
"price": 25,
|
||||
}
|
||||
@@ -62,11 +88,15 @@ class TestPmsFolio(TestHotel):
|
||||
)
|
||||
|
||||
def create_multiproperty_scenario(self):
|
||||
self.create_common_scenario()
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -75,6 +105,9 @@ class TestPmsFolio(TestHotel):
|
||||
"name": "Property_2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -83,6 +116,9 @@ class TestPmsFolio(TestHotel):
|
||||
"name": "Property_3",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -101,7 +137,7 @@ class TestPmsFolio(TestHotel):
|
||||
{
|
||||
"name": "partner1",
|
||||
"is_agency": True,
|
||||
"invoice_agency": True,
|
||||
"invoice_to_agency": True,
|
||||
"default_commission": 15,
|
||||
"sale_channel_id": saleChannel.id,
|
||||
}
|
||||
@@ -149,7 +185,7 @@ class TestPmsFolio(TestHotel):
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
)
|
||||
r1.left_for_checkin = False
|
||||
r1.allowed_checkin = False
|
||||
|
||||
self.env["pms.reservation"].create(
|
||||
{
|
||||
@@ -250,3 +286,35 @@ class TestPmsFolio(TestHotel):
|
||||
"closure_reason_id": cl_reason.id,
|
||||
}
|
||||
)
|
||||
|
||||
def _test_compute_currency(self):
|
||||
self.create_common_scenario()
|
||||
self.currency1 = self.env["res.currency"].create(
|
||||
{
|
||||
"name": "currency1",
|
||||
"symbol": "C",
|
||||
}
|
||||
)
|
||||
self.pricelist = self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "pricelist 1",
|
||||
"pms_property_ids": [
|
||||
(4, self.property.id),
|
||||
],
|
||||
"currency_id": self.currency1.id,
|
||||
}
|
||||
)
|
||||
self.reservation1 = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": datetime.datetime.now(),
|
||||
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
|
||||
"partner_id": self.env.ref("base.res_partner_12").id,
|
||||
"pricelist_id": self.pricelist.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(
|
||||
self.currency1.id,
|
||||
self.reservation1.folio_id.currency_id.id,
|
||||
"Currency must match",
|
||||
)
|
||||
|
||||
@@ -1,23 +1,51 @@
|
||||
import datetime
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsFolioInvoice(TestHotel):
|
||||
class TestPmsFolioInvoice(common.SavepointCase):
|
||||
def setUp(self):
|
||||
super(TestPmsFolioInvoice, self).setUp()
|
||||
|
||||
def create_common_scenario(self):
|
||||
# create a room type availability
|
||||
self.room_type_availability = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create({"name": "Availability plan for TEST"})
|
||||
# sequences
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.room_type_availability = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability plan for TEST"}
|
||||
)
|
||||
# create a property
|
||||
self.property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
# create room type class
|
||||
@@ -30,7 +58,7 @@ class TestPmsFolioInvoice(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.property.id],
|
||||
"name": "Double Test",
|
||||
"code_type": "DBL_Test",
|
||||
"default_code": "DBL_Test",
|
||||
"class_id": self.room_type_class.id,
|
||||
"price": 25,
|
||||
}
|
||||
|
||||
@@ -5,13 +5,42 @@ from odoo.tests import common, tagged
|
||||
|
||||
|
||||
@tagged("standard", "nice")
|
||||
class TestPmsPricelist(common.TransactionCase):
|
||||
class TestPmsPricelist(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# sequences
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
# create property
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -20,6 +49,9 @@ class TestPmsPricelist(common.TransactionCase):
|
||||
"name": "Property_2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -28,6 +60,9 @@ class TestPmsPricelist(common.TransactionCase):
|
||||
"name": "Property_3",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.room_type_class = self.env["pms.room.type.class"].create(
|
||||
@@ -38,7 +73,7 @@ class TestPmsPricelist(common.TransactionCase):
|
||||
{
|
||||
"pms_property_ids": [self.property1.id, self.property2.id],
|
||||
"name": "Single",
|
||||
"code_type": "SIN",
|
||||
"default_code": "SIN",
|
||||
"class_id": self.room_type_class.id,
|
||||
"list_price": 30,
|
||||
}
|
||||
@@ -151,7 +186,7 @@ class TestPmsPricelist(common.TransactionCase):
|
||||
|
||||
def test_availability_plan_property_integrity(self):
|
||||
self.create_common_scenario()
|
||||
self.availability_plan = self.env["pms.room.type.availability.plan"].create(
|
||||
self.availability_plan = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability Plan", "pms_property_ids": [self.property1.id]}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
|
||||
@@ -5,7 +5,7 @@ from freezegun import freeze_time
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsPricelistRules(common.TransactionCase):
|
||||
class TestPmsPricelistRules(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
self.product_template = self.env["product.template"].create(
|
||||
{"name": "Template1"}
|
||||
@@ -14,18 +14,46 @@ class TestPmsPricelistRules(common.TransactionCase):
|
||||
{"name": "Category1"}
|
||||
)
|
||||
|
||||
self.availability_plan1 = self.env["pms.room.type.availability.plan"].create(
|
||||
self.availability_plan1 = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability 1"}
|
||||
)
|
||||
|
||||
self.availability_plan2 = self.env["pms.room.type.availability.plan"].create(
|
||||
self.availability_plan2 = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability"}
|
||||
)
|
||||
# sequences
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -34,6 +62,9 @@ class TestPmsPricelistRules(common.TransactionCase):
|
||||
"name": "Property_2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -45,7 +76,7 @@ class TestPmsPricelistRules(common.TransactionCase):
|
||||
{
|
||||
"pms_property_ids": [self.property1.id, self.property2.id],
|
||||
"name": "Single",
|
||||
"code_type": "SIN",
|
||||
"default_code": "SIN",
|
||||
"class_id": self.room_type_class.id,
|
||||
"list_price": 30,
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ from odoo.exceptions import ValidationError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsResUser(common.TransactionCase):
|
||||
class TestPmsResUser(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# create a room type availability
|
||||
self.room_type_availability = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create({"name": "Availability plan 1"})
|
||||
self.room_type_availability = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability plan 1"}
|
||||
)
|
||||
|
||||
# create a company and properties
|
||||
self.company_A = self.env["res.company"].create(
|
||||
@@ -20,11 +20,62 @@ class TestPmsResUser(common.TransactionCase):
|
||||
"name": "Pms_Company2",
|
||||
}
|
||||
)
|
||||
self.folio_sequenceA = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.company_A.id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequenceA = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.company_A.id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequenceA = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.company_A.id,
|
||||
}
|
||||
)
|
||||
self.folio_sequenceB = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.company_B.id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequenceB = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.company_B.id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequenceB = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.company_B.id,
|
||||
}
|
||||
)
|
||||
self.property_A1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Pms_property",
|
||||
"company_id": self.company_A.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequenceA.id,
|
||||
"reservation_sequence_id": self.reservation_sequenceA.id,
|
||||
"checkin_sequence_id": self.checkin_sequenceA.id,
|
||||
}
|
||||
)
|
||||
self.property_A2 = self.env["pms.property"].create(
|
||||
@@ -32,6 +83,9 @@ class TestPmsResUser(common.TransactionCase):
|
||||
"name": "Pms_property2",
|
||||
"company_id": self.company_A.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequenceA.id,
|
||||
"reservation_sequence_id": self.reservation_sequenceA.id,
|
||||
"checkin_sequence_id": self.checkin_sequenceA.id,
|
||||
}
|
||||
)
|
||||
self.property_B1 = self.env["pms.property"].create(
|
||||
@@ -39,6 +93,9 @@ class TestPmsResUser(common.TransactionCase):
|
||||
"name": "Pms_propertyB1",
|
||||
"company_id": self.company_B.id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequenceB.id,
|
||||
"reservation_sequence_id": self.reservation_sequenceB.id,
|
||||
"checkin_sequence_id": self.checkin_sequenceB.id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -3,25 +3,61 @@ import datetime
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
@freeze_time("2012-01-14")
|
||||
class TestPmsReservations(TestHotel):
|
||||
class TestPmsReservations(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# create a room type availability
|
||||
self.room_type_availability = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create({"name": "Availability plan for TEST"})
|
||||
|
||||
self.test_pricelist1 = self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "test pricelist 1",
|
||||
}
|
||||
)
|
||||
# create a room type availability
|
||||
self.room_type_availability = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
}
|
||||
)
|
||||
|
||||
# create a sequences
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
# create a property
|
||||
self.property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"default_pricelist_id": self.test_pricelist1.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -35,7 +71,7 @@ class TestPmsReservations(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.property.id],
|
||||
"name": "Double Test",
|
||||
"code_type": "DBL_Test",
|
||||
"default_code": "DBL_Test",
|
||||
"class_id": self.room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -70,11 +106,15 @@ class TestPmsReservations(TestHotel):
|
||||
self.demo_user = self.env.ref("base.user_admin")
|
||||
|
||||
def create_multiproperty_scenario(self):
|
||||
self.create_common_scenario()
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -83,6 +123,9 @@ class TestPmsReservations(TestHotel):
|
||||
"name": "Property_2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -91,6 +134,9 @@ class TestPmsReservations(TestHotel):
|
||||
"name": "Property_3",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.room_type_class = self.env["pms.room.type.class"].create(
|
||||
@@ -109,6 +155,7 @@ class TestPmsReservations(TestHotel):
|
||||
# reservation should start on checkin day
|
||||
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
today = fields.date.today()
|
||||
checkin = today + datetime.timedelta(days=8)
|
||||
checkout = checkin + datetime.timedelta(days=11)
|
||||
@@ -116,9 +163,9 @@ class TestPmsReservations(TestHotel):
|
||||
reservation_vals = {
|
||||
"checkin": checkin,
|
||||
"checkout": checkout,
|
||||
"room_type_id": self.room_type_3.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"partner_id": customer.id,
|
||||
"pms_property_id": self.main_hotel_property.id,
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
|
||||
# ACT
|
||||
@@ -134,7 +181,7 @@ class TestPmsReservations(TestHotel):
|
||||
def test_create_reservation_end_date(self):
|
||||
# TEST CASE
|
||||
# reservation should end on checkout day
|
||||
|
||||
self.create_common_scenario()
|
||||
# ARRANGE
|
||||
today = fields.date.today()
|
||||
checkin = today + datetime.timedelta(days=8)
|
||||
@@ -143,9 +190,9 @@ class TestPmsReservations(TestHotel):
|
||||
reservation_vals = {
|
||||
"checkin": checkin,
|
||||
"checkout": checkout,
|
||||
"room_type_id": self.room_type_3.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"partner_id": customer.id,
|
||||
"pms_property_id": self.main_hotel_property.id,
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
|
||||
# ACT
|
||||
@@ -637,7 +684,7 @@ class TestPmsReservations(TestHotel):
|
||||
self.assertEqual(r1, reservations[0])
|
||||
|
||||
@freeze_time("1981-11-01")
|
||||
def test_order_priority_left_for_checkin(self):
|
||||
def test_order_priority_allowed_checkin(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
r1 = self.env["pms.reservation"].create(
|
||||
@@ -658,7 +705,7 @@ class TestPmsReservations(TestHotel):
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
)
|
||||
r1.left_for_checkin = False
|
||||
r1.allowed_checkin = False
|
||||
# ACT
|
||||
reservations = self.env["pms.reservation"].search(
|
||||
[("pms_property_id", "=", self.property.id)]
|
||||
@@ -667,7 +714,7 @@ class TestPmsReservations(TestHotel):
|
||||
self.assertEqual(r1, reservations[0])
|
||||
|
||||
@freeze_time("1981-11-01")
|
||||
def test_order_priority_left_for_checkout(self):
|
||||
def test_order_priority_allowed_checkout(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
r1 = self.env["pms.reservation"].create(
|
||||
@@ -688,7 +735,7 @@ class TestPmsReservations(TestHotel):
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
)
|
||||
r1.left_for_checkout = True
|
||||
r1.allowed_checkout = True
|
||||
# ACT
|
||||
reservations = self.env["pms.reservation"].search(
|
||||
[("pms_property_id", "=", self.property.id)]
|
||||
@@ -816,7 +863,9 @@ class TestPmsReservations(TestHotel):
|
||||
checkin.flush()
|
||||
|
||||
# ACT
|
||||
r1.action_reservation_checkout()
|
||||
with freeze_time("1981-11-02"):
|
||||
r1._cache.clear()
|
||||
r1.action_reservation_checkout()
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
@@ -861,7 +910,7 @@ class TestPmsReservations(TestHotel):
|
||||
(4, self.property2.id),
|
||||
],
|
||||
"name": "Single",
|
||||
"code_type": "SIN",
|
||||
"default_code": "SIN",
|
||||
"class_id": self.room_type_class.id,
|
||||
"list_price": 30,
|
||||
}
|
||||
@@ -903,3 +952,622 @@ class TestPmsReservations(TestHotel):
|
||||
with self.subTest(k=test_case):
|
||||
with self.assertRaises(ValidationError):
|
||||
self.reservation_test.write(test_case)
|
||||
|
||||
@freeze_time("1950-11-01")
|
||||
def _test_check_date_order(self):
|
||||
self.create_common_scenario()
|
||||
customer = self.env.ref("base.res_partner_12")
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": fields.date.today(),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=3),
|
||||
"partner_id": customer.id,
|
||||
}
|
||||
)
|
||||
|
||||
reservation.flush()
|
||||
self.assertEqual(
|
||||
str(reservation.date_order),
|
||||
str(fields.date.today()),
|
||||
"Date Order isn't correct",
|
||||
)
|
||||
|
||||
def _test_check_checkin_datetime(self):
|
||||
self.create_common_scenario()
|
||||
customer = self.env.ref("base.res_partner_12")
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=300),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=305),
|
||||
"partner_id": customer.id,
|
||||
}
|
||||
)
|
||||
r = reservation.checkin
|
||||
checkin_expected = datetime.datetime(r.year, r.month, r.day, 14, 00)
|
||||
# checkin_expected = checkin_expected.astimezone(self.property.tz.value)
|
||||
|
||||
self.assertEqual(
|
||||
str(reservation.checkin_datetime),
|
||||
str(checkin_expected),
|
||||
"Date Order isn't correct",
|
||||
)
|
||||
|
||||
def test_check_allowed_room_ids(self):
|
||||
self.create_common_scenario()
|
||||
customer = self.env.ref("base.res_partner_12")
|
||||
availability_rule = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"availability_plan_id": self.room_type_availability.id,
|
||||
"date": fields.date.today() + datetime.timedelta(days=153),
|
||||
}
|
||||
)
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=150),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=152),
|
||||
"partner_id": customer.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"pricelist_id": self.test_pricelist1.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(
|
||||
reservation.allowed_room_ids,
|
||||
availability_rule.room_type_id.room_ids,
|
||||
"Rooms allowed don't match",
|
||||
)
|
||||
|
||||
def _test_partner_is_agency(self):
|
||||
self.create_common_scenario()
|
||||
sale_channel1 = self.env["pms.sale.channel"].create(
|
||||
{"name": "Test Indirect", "channel_type": "indirect"}
|
||||
)
|
||||
agency = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "partner1",
|
||||
"is_agency": True,
|
||||
"sale_channel_id": sale_channel1.id,
|
||||
}
|
||||
)
|
||||
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=150),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=152),
|
||||
# "partner_id": False,
|
||||
"agency_id": agency.id,
|
||||
# "folio_id":False,
|
||||
}
|
||||
)
|
||||
|
||||
reservation.flush()
|
||||
|
||||
self.assertEqual(
|
||||
reservation.partner_id.id,
|
||||
agency.id,
|
||||
"Partner_id doesn't match with agency_id",
|
||||
)
|
||||
|
||||
def test_agency_pricelist(self):
|
||||
self.create_common_scenario()
|
||||
sale_channel1 = self.env["pms.sale.channel"].create(
|
||||
{
|
||||
"name": "Test Indirect",
|
||||
"channel_type": "indirect",
|
||||
"product_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
}
|
||||
)
|
||||
agency = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "partner1",
|
||||
"is_agency": True,
|
||||
"sale_channel_id": sale_channel1.id,
|
||||
"apply_pricelist": True,
|
||||
}
|
||||
)
|
||||
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=150),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=152),
|
||||
"agency_id": agency.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
reservation.pricelist_id.id,
|
||||
reservation.agency_id.property_product_pricelist.id,
|
||||
"Rervation pricelist doesn't match with Agency pricelist",
|
||||
)
|
||||
|
||||
def test_compute_access_url(self):
|
||||
self.create_common_scenario()
|
||||
customer = self.env.ref("base.res_partner_12")
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.property.id,
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=150),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=152),
|
||||
"partner_id": customer.id,
|
||||
}
|
||||
)
|
||||
|
||||
url = "/my/reservations/%s" % reservation.id
|
||||
self.assertEqual(reservation.access_url, url, "Reservation url isn't correct")
|
||||
|
||||
def test_compute_ready_for_checkin(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Miguel",
|
||||
"phone": "654667733",
|
||||
"email": "miguel@example.com",
|
||||
}
|
||||
)
|
||||
self.host2 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Brais",
|
||||
"phone": "654437733",
|
||||
"email": "brais@example.com",
|
||||
}
|
||||
)
|
||||
self.reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": "2012-01-14",
|
||||
"checkout": "2012-01-17",
|
||||
"partner_id": self.host1.id,
|
||||
"allowed_checkin": True,
|
||||
"pms_property_id": self.property.id,
|
||||
"adults": 3,
|
||||
}
|
||||
)
|
||||
self.checkin1 = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": self.host1.id,
|
||||
"reservation_id": self.reservation.id,
|
||||
}
|
||||
)
|
||||
self.checkin2 = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": self.host2.id,
|
||||
"reservation_id": self.reservation.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.reservation.checkin_partner_ids = [
|
||||
(6, 0, [self.checkin1.id, self.checkin2.id])
|
||||
]
|
||||
|
||||
self.assertTrue(
|
||||
self.reservation.ready_for_checkin,
|
||||
"Reservation should is ready for checkin",
|
||||
)
|
||||
|
||||
def test_check_checkin_less_checkout(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=3),
|
||||
"checkout": fields.date.today(),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_adults(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=3),
|
||||
"checkout": fields.date.today(),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"adults": 4,
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_arrival_hour(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today(),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=3),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
"arrival_hour": "14:00:00",
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_departure_hour(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today(),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=3),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
"departure_hour": "14:00:00",
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_property_integrity_room(self):
|
||||
self.create_common_scenario()
|
||||
self.property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist1.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
self.room_type_double.pms_property_ids = [
|
||||
(6, 0, [self.property.id, self.property2.id])
|
||||
]
|
||||
with self.assertRaises(ValidationError):
|
||||
self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today(),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=3),
|
||||
"pms_property_id": self.property2.id,
|
||||
"partner_id": self.host1.id,
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"preferred_room_id": self.room1.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_shared_folio_true(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
self.reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=60),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=65),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
}
|
||||
)
|
||||
self.reservation2 = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=60),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=64),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
"folio_id": self.reservation.folio_id.id,
|
||||
}
|
||||
)
|
||||
self.assertTrue(
|
||||
self.reservation.shared_folio,
|
||||
"Folio.reservations > 1, so reservation.shared_folio must be True",
|
||||
)
|
||||
|
||||
def test_shared_folio_false(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
self.reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=60),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=65),
|
||||
"pms_property_id": self.property.id,
|
||||
"partner_id": self.host1.id,
|
||||
}
|
||||
)
|
||||
self.assertFalse(
|
||||
self.reservation.shared_folio,
|
||||
"Folio.reservations = 1, so reservation.shared_folio must be False",
|
||||
)
|
||||
|
||||
@freeze_time("1982-11-01")
|
||||
def test_reservation_action_cancel_fail(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today(),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=1),
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"partner_id": self.host1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
)
|
||||
|
||||
reservation.state = "cancelled"
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
reservation.action_cancel()
|
||||
|
||||
@freeze_time("1983-11-01")
|
||||
def test_cancelation_reason_noshow(self):
|
||||
self.create_common_scenario()
|
||||
Pricelist = self.env["product.pricelist"]
|
||||
self.cancelation_rule = self.env["pms.cancelation.rule"].create(
|
||||
{
|
||||
"name": "Cancelation Rule Test",
|
||||
"pms_property_ids": [self.property.id],
|
||||
"penalty_noshow": 50,
|
||||
}
|
||||
)
|
||||
|
||||
self.pricelist = Pricelist.create(
|
||||
{
|
||||
"name": "Pricelist Test",
|
||||
"pms_property_ids": [self.property.id],
|
||||
"cancelation_rule_id": self.cancelation_rule.id,
|
||||
}
|
||||
)
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=-5),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=-3),
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"partner_id": self.host1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"pricelist_id": self.pricelist.id,
|
||||
}
|
||||
)
|
||||
|
||||
reservation.action_cancel()
|
||||
reservation.flush()
|
||||
self.assertEqual(
|
||||
reservation.cancelled_reason,
|
||||
"noshow",
|
||||
"If reservation has already passed and no checkin,"
|
||||
"cancelled_reason must be 'noshow'",
|
||||
)
|
||||
|
||||
@freeze_time("1984-11-01")
|
||||
def test_cancelation_reason_intime(self):
|
||||
self.create_common_scenario()
|
||||
Pricelist = self.env["product.pricelist"]
|
||||
self.cancelation_rule = self.env["pms.cancelation.rule"].create(
|
||||
{
|
||||
"name": "Cancelation Rule Test",
|
||||
"pms_property_ids": [self.property.id],
|
||||
"days_intime": 3,
|
||||
}
|
||||
)
|
||||
|
||||
self.pricelist = Pricelist.create(
|
||||
{
|
||||
"name": "Pricelist Test",
|
||||
"pms_property_ids": [self.property.id],
|
||||
"cancelation_rule_id": self.cancelation_rule.id,
|
||||
}
|
||||
)
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=5),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=8),
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"partner_id": self.host1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"pricelist_id": self.pricelist.id,
|
||||
}
|
||||
)
|
||||
|
||||
reservation.action_cancel()
|
||||
reservation.flush()
|
||||
|
||||
self.assertEqual(reservation.cancelled_reason, "intime", "-----------")
|
||||
|
||||
@freeze_time("1985-11-01")
|
||||
def _test_cancelation_reason_late(self):
|
||||
self.create_common_scenario()
|
||||
Pricelist = self.env["product.pricelist"]
|
||||
self.cancelation_rule = self.env["pms.cancelation.rule"].create(
|
||||
{
|
||||
"name": "Cancelation Rule Test",
|
||||
"pms_property_ids": [self.property.id],
|
||||
"days_late": 3,
|
||||
}
|
||||
)
|
||||
|
||||
self.pricelist = Pricelist.create(
|
||||
{
|
||||
"name": "Pricelist Test",
|
||||
"pms_property_ids": [self.property.id],
|
||||
"cancelation_rule_id": self.cancelation_rule.id,
|
||||
}
|
||||
)
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Host1",
|
||||
}
|
||||
)
|
||||
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today() + datetime.timedelta(days=1),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=4),
|
||||
"room_type_id": self.room_type_double.id,
|
||||
"partner_id": self.host1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"pricelist_id": self.pricelist.id,
|
||||
}
|
||||
)
|
||||
reservation.action_cancel()
|
||||
reservation.flush()
|
||||
self.assertEqual(reservation.cancelled_reason, "late", "-----------")
|
||||
|
||||
def test_compute_checkin_partner_count(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Miguel",
|
||||
"phone": "654667733",
|
||||
"email": "miguel@example.com",
|
||||
}
|
||||
)
|
||||
self.host2 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Brais",
|
||||
"phone": "654437733",
|
||||
"email": "brais@example.com",
|
||||
}
|
||||
)
|
||||
self.reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": "2013-01-14",
|
||||
"checkout": "2013-01-17",
|
||||
"partner_id": self.host1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"adults": 3,
|
||||
}
|
||||
)
|
||||
self.checkin1 = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": self.host1.id,
|
||||
"reservation_id": self.reservation.id,
|
||||
}
|
||||
)
|
||||
self.checkin2 = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": self.host2.id,
|
||||
"reservation_id": self.reservation.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.reservation.checkin_partner_ids = [
|
||||
(6, 0, [self.checkin1.id, self.checkin2.id])
|
||||
]
|
||||
|
||||
self.assertEqual(
|
||||
self.reservation.checkin_partner_count,
|
||||
len(self.reservation.checkin_partner_ids),
|
||||
"Checkin_partner_count must be match with number of checkin_partner_ids",
|
||||
)
|
||||
|
||||
def test_compute_checkin_partner_pending_count(self):
|
||||
self.create_common_scenario()
|
||||
self.host1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Miguel",
|
||||
"phone": "654667733",
|
||||
"email": "miguel@example.com",
|
||||
}
|
||||
)
|
||||
self.host2 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Brais",
|
||||
"phone": "654437733",
|
||||
"email": "brais@example.com",
|
||||
}
|
||||
)
|
||||
self.reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": "2014-01-14",
|
||||
"checkout": "2014-01-17",
|
||||
"partner_id": self.host1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"adults": 3,
|
||||
}
|
||||
)
|
||||
self.checkin1 = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": self.host1.id,
|
||||
"reservation_id": self.reservation.id,
|
||||
}
|
||||
)
|
||||
self.checkin2 = self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": self.host2.id,
|
||||
"reservation_id": self.reservation.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.reservation.checkin_partner_ids = [
|
||||
(6, 0, [self.checkin1.id, self.checkin2.id])
|
||||
]
|
||||
|
||||
count_expected = self.reservation.adults - len(
|
||||
self.reservation.checkin_partner_ids
|
||||
)
|
||||
self.assertEqual(
|
||||
self.reservation.checkin_partner_pending_count,
|
||||
count_expected,
|
||||
"Checkin_partner_pending_count isn't correct",
|
||||
)
|
||||
|
||||
@freeze_time("1982-11-01")
|
||||
def test_reservation_action_checkout_fail(self):
|
||||
self.create_common_scenario()
|
||||
host = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Miguel",
|
||||
"phone": "654667733",
|
||||
"email": "miguel@example.com",
|
||||
}
|
||||
)
|
||||
reservation = self.env["pms.reservation"].create(
|
||||
{
|
||||
"checkin": fields.date.today(),
|
||||
"checkout": fields.date.today() + datetime.timedelta(days=1),
|
||||
"partner_id": host.id,
|
||||
"allowed_checkout": True,
|
||||
"pms_property_id": self.property.id,
|
||||
}
|
||||
)
|
||||
|
||||
with self.assertRaises(UserError):
|
||||
reservation.action_reservation_checkout()
|
||||
|
||||
@@ -1,54 +1,36 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import common
|
||||
|
||||
from .common import TestPms
|
||||
|
||||
|
||||
class TestPmsRoom(common.TransactionCase):
|
||||
def create_common_scenario(self):
|
||||
self.property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
|
||||
self.property2 = self.env["pms.property"].create(
|
||||
class TestPmsRoom(TestPms):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.pms_property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
self.property3 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_3",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.room_type_class = self.env["pms.room.type.class"].create(
|
||||
{"name": "Room Class", "code_class": "ROOM"}
|
||||
)
|
||||
|
||||
self.room_type = self.env["pms.room.type"].create(
|
||||
self.room_type1 = self.env["pms.room.type"].create(
|
||||
{
|
||||
"pms_property_ids": [self.property1.id, self.property2.id],
|
||||
"pms_property_ids": [self.pms_property1.id, self.pms_property2.id],
|
||||
"name": "Single",
|
||||
"code_type": "SIN",
|
||||
"class_id": self.room_type_class.id,
|
||||
"default_code": "SIN",
|
||||
"class_id": self.room_type_class1.id,
|
||||
"list_price": 30,
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_property_floor(self):
|
||||
def test_check_property_ubication(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
floor = self.env["pms.floor"].create(
|
||||
ubication1 = self.env["pms.ubication"].create(
|
||||
{
|
||||
"name": "Floor",
|
||||
"name": "UbicationTest",
|
||||
"pms_property_ids": [
|
||||
(4, self.property1.id),
|
||||
(4, self.pms_property1.id),
|
||||
],
|
||||
}
|
||||
)
|
||||
@@ -59,15 +41,21 @@ class TestPmsRoom(common.TransactionCase):
|
||||
self.env["pms.room"].create(
|
||||
{
|
||||
"name": "Room 101",
|
||||
"pms_property_id": self.property2.id,
|
||||
"room_type_id": self.room_type.id,
|
||||
"floor_id": floor.id,
|
||||
"pms_property_id": self.pms_property2.id,
|
||||
"room_type_id": self.room_type1.id,
|
||||
"ubication_id": ubication1.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_check_property_room_type(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
self.pms_property3 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property_3",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
# ACT & ARRANGE
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="Room has been created and it should't"
|
||||
@@ -75,7 +63,7 @@ class TestPmsRoom(common.TransactionCase):
|
||||
self.env["pms.room"].create(
|
||||
{
|
||||
"name": "Room 101",
|
||||
"pms_property_id": self.property3.id,
|
||||
"room_type_id": self.room_type.id,
|
||||
"pms_property_id": self.pms_property3.id,
|
||||
"room_type_id": self.room_type1.id,
|
||||
}
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,57 +2,47 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests.common import SavepointCase
|
||||
|
||||
from .common import TestPms
|
||||
|
||||
|
||||
class TestRoomTypeClass(SavepointCase):
|
||||
class TestRoomTypeClass(TestPms):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.p1 = self.browse_ref("pms.main_pms_property")
|
||||
self.m1 = self.p1.company_id
|
||||
self.p2 = self.env["pms.property"].create(
|
||||
self.company2 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "p2",
|
||||
"company_id": self.m1.id,
|
||||
"default_pricelist_id": self.ref("product.list0"),
|
||||
"name": "Company 2",
|
||||
}
|
||||
)
|
||||
self.m2 = self.env["res.company"].create(
|
||||
self.pms_property3 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Company m2",
|
||||
}
|
||||
)
|
||||
self.p3 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "p3",
|
||||
"company_id": self.m2.id,
|
||||
"default_pricelist_id": self.ref("product.list0"),
|
||||
"name": "Property 3",
|
||||
"company_id": self.company2.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class TestRoomTypeClassCodePropertyIntegrity(TestRoomTypeClass):
|
||||
# external integrity
|
||||
def test_external_case_01(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has property p1
|
||||
- p1 has company m1
|
||||
ACT: - create a new cl2 class
|
||||
- cl2 has code c1
|
||||
- cl2 has property p1
|
||||
- p1 has company m1
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has pms_property1
|
||||
- pms_property1 has company company1
|
||||
ACT: - create a new room_type_class2 class
|
||||
- room_type_class2 has code c1
|
||||
- room_type_class2 has pms_property1
|
||||
- pms_property1 has company company1
|
||||
POST: - Integrity error: the room type already exists
|
||||
- cl2 not created
|
||||
- room_type_class2 not created
|
||||
"""
|
||||
# ARRANGE
|
||||
# cl1
|
||||
# room_type_class1
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id])],
|
||||
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -60,36 +50,44 @@ class TestRoomTypeClassCodePropertyIntegrity(TestRoomTypeClass):
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="The room type class has been created and it shouldn't"
|
||||
):
|
||||
# cl2
|
||||
# room_type_class2
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl2",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id])],
|
||||
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
|
||||
}
|
||||
)
|
||||
|
||||
def test_external_case_02(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has property p1
|
||||
- p1 has company m1
|
||||
ACT: - create a new cl2 class
|
||||
- cl2 has code c1
|
||||
- cl2 has property p1, p2, p3
|
||||
- p1, p2 has company m1
|
||||
- p3 has company m2
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has property pms_property1
|
||||
- pms_property1 has company company1
|
||||
ACT: - create a new room_type_class2 class
|
||||
- room_type_class2 has code c1
|
||||
- room_type_class2 has property pms_property1, pms_property2,
|
||||
pms_property3
|
||||
- pms_property1, pms_property2 has company company1
|
||||
- pms_property3 has company company2
|
||||
POST: - Integrity error: the room type class already exists
|
||||
- cl2 not created
|
||||
- room_type_class2 not created
|
||||
"""
|
||||
# ARRANGE
|
||||
# cl1
|
||||
self.pms_property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property 2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
# room_type_class1
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id])],
|
||||
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -97,158 +95,184 @@ class TestRoomTypeClassCodePropertyIntegrity(TestRoomTypeClass):
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="The room type class has been created and it shouldn't"
|
||||
):
|
||||
# cl2
|
||||
# room_type_class2
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl2",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id, self.p2.id, self.p3.id])],
|
||||
"pms_property_ids": [
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[
|
||||
self.pms_property1.id,
|
||||
self.pms_property2.id,
|
||||
self.pms_property3.id,
|
||||
],
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class TestRoomTypeClassCodePropertyUniqueness(TestRoomTypeClass):
|
||||
# test with one room type class
|
||||
def test_single_case_01(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has 2 properties p1 and p2
|
||||
- p1 and p2 have the same company m1
|
||||
ACT: - search room type class with code c1 and property p1
|
||||
- p1 has company m1
|
||||
POST: - only cl1 room type class found
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has 2 properties pms_property1 and pms_property2
|
||||
- pms_property_1 and pms_property2 have the same company company1
|
||||
ACT: - search room type class with code c1 and pms_property1
|
||||
- pms_property1 has company company1
|
||||
POST: - only room_type_class1 room type class found
|
||||
"""
|
||||
# ARRANGE
|
||||
cl1 = self.env["pms.room.type.class"].create(
|
||||
room_type_class1 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
|
||||
"pms_property_ids": [
|
||||
(6, 0, [self.pms_property1.id, self.pms_property3.id])
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p1.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property1.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
room_type_class.id, cl1.id, "Expected room type class not found"
|
||||
room_type_classes.id,
|
||||
room_type_class1.id,
|
||||
"Expected room type class not found",
|
||||
)
|
||||
|
||||
def test_single_case_02(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has 2 properties p1 and p3
|
||||
- p1 and p2 have different companies
|
||||
- p1 have company m1 and p3 have company m2
|
||||
ACT: - search room type class with code c1 and property p1
|
||||
- p1 has company m1
|
||||
POST: - only cl1 room type found
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has 2 properties pms_property1 and pms_property3
|
||||
- pms_property1 and pms_property2 have different companies
|
||||
- pms_property1 have company company1 and pms_property3 have company2
|
||||
ACT: - search room type class with code c1 and property pms_property1
|
||||
- pms_property1 has company company1
|
||||
POST: - only room_type_class1 room type found
|
||||
"""
|
||||
# ARRANGE
|
||||
cl1 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
|
||||
"pms_property_ids": [
|
||||
(6, 0, [self.pms_property1.id, self.pms_property3.id])
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p1.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property1.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
room_type_class.id, cl1.id, "Expected room type class not found"
|
||||
room_type_classes.id, cl1.id, "Expected room type class not found"
|
||||
)
|
||||
|
||||
def test_single_case_03(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 with 2 properties p1 and p2
|
||||
- p1 and p2 have same company m1
|
||||
ACT: - search room type class with code c1 and property p3
|
||||
- p3 have company m2
|
||||
PRE: - room_type_class1 exists
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 with 2 properties pms_property1 and pms_property2
|
||||
- pms_property1 and pms_property2 have same company company1
|
||||
ACT: - search room type class with code c1 and property pms_property3
|
||||
- pms_property3 have company company2
|
||||
POST: - no room type found
|
||||
"""
|
||||
# ARRANGE
|
||||
# cl1
|
||||
self.pms_property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property 2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
# room_type_class1
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id, self.p2.id])],
|
||||
"pms_property_ids": [
|
||||
(6, 0, [self.pms_property1.id, self.pms_property2.id])
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p3.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property3.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertFalse(
|
||||
room_type_class, "Room type class found but it should not have found any"
|
||||
room_type_classes, "Room type class found but it should not have found any"
|
||||
)
|
||||
|
||||
def test_single_case_04(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 properties are null
|
||||
ACT: - search room type class with code c1 and property p1
|
||||
- p1 have company m1
|
||||
POST: - only cl1 room type class found
|
||||
PRE: - room_type_class1 exists
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 properties are null
|
||||
ACT: - search room type class with code c1 and property pms_property1
|
||||
- pms_property1 have company company1
|
||||
POST: - only room_type_class1 room type class found
|
||||
"""
|
||||
# ARRANGE
|
||||
cl1 = self.env["pms.room.type.class"].create(
|
||||
room_type_class1 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": False,
|
||||
}
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p1.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property1.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
room_type_class.id, cl1.id, "Expected room type class not found"
|
||||
room_type_classes.id,
|
||||
room_type_class1.id,
|
||||
"Expected room type class not found",
|
||||
)
|
||||
|
||||
# tests with more than one room type class
|
||||
def test_multiple_case_01(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has 2 properties p1 and p2
|
||||
- p1 and p2 have the same company m1
|
||||
- room type class cl2 exists
|
||||
- cl2 has code c1
|
||||
- cl2 has no properties
|
||||
ACT: - search room type class with code c1 and property p1
|
||||
- p1 have company m1
|
||||
POST: - only cl1 room type class found
|
||||
PRE: - room_type_class1 exists
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has 2 properties pms_property1 and pms_property2
|
||||
- pms_property1 and pms_property2 have the same company company1
|
||||
- room type class room_type_class2 exists
|
||||
- room_type_class2 has code c1
|
||||
- room_type_class2 has no properties
|
||||
ACT: - search room type class with code c1 and property pms_property1
|
||||
- pms_property1 have company company1
|
||||
POST: - only room_type_class1 room type class found
|
||||
"""
|
||||
# ARRANGE
|
||||
cl1 = self.env["pms.room.type.class"].create(
|
||||
room_type_class1 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id, self.p3.id])],
|
||||
"pms_property_ids": [
|
||||
(6, 0, [self.pms_property1.id, self.pms_property3.id])
|
||||
],
|
||||
}
|
||||
)
|
||||
# cl2
|
||||
# room_type_class2
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl2",
|
||||
@@ -258,38 +282,47 @@ class TestRoomTypeClassCodePropertyUniqueness(TestRoomTypeClass):
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p1.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property1.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
room_type_class.id, cl1.id, "Expected room type class not found"
|
||||
room_type_classes.id,
|
||||
room_type_class1.id,
|
||||
"Expected room type class not found",
|
||||
)
|
||||
|
||||
def test_multiple_case_02(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has property p1
|
||||
- p1 have the company m1
|
||||
- room type class cl2 exists
|
||||
- cl2 has code c1
|
||||
- cl2 has no properties
|
||||
ACT: - search room type class with code c1 and property p2
|
||||
- p2 have company m1
|
||||
POST: - only cl1 room type class found
|
||||
PRE: - room_type_class1 exists
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has property pms_property1
|
||||
- pms_property1 have the company company1
|
||||
- room type class room_type_class2 exists
|
||||
- room_type_class2 has code c1
|
||||
- room_type_class2 has no properties
|
||||
ACT: - search room type class with code c1 and pms_property2
|
||||
- pms_property2 have company company1
|
||||
POST: - only room_type_class1 room type class found
|
||||
"""
|
||||
# ARRANGE
|
||||
# cl1
|
||||
self.env["pms.room.type.class"].create(
|
||||
self.pms_property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id])],
|
||||
"name": "Property 2",
|
||||
"company_id": self.company1.id,
|
||||
"default_pricelist_id": self.pricelist1.id,
|
||||
}
|
||||
)
|
||||
cl2 = self.env["pms.room.type.class"].create(
|
||||
# room_type_class1
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
|
||||
}
|
||||
)
|
||||
room_type_class2 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl2",
|
||||
"code_class": "c1",
|
||||
@@ -298,38 +331,40 @@ class TestRoomTypeClassCodePropertyUniqueness(TestRoomTypeClass):
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p2.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property2.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
room_type_class.id, cl2.id, "Expected room type class not found"
|
||||
room_type_classes.id,
|
||||
room_type_class2.id,
|
||||
"Expected room type class not found",
|
||||
)
|
||||
|
||||
def test_multiple_case_03(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has property p1
|
||||
- p1 have the company m1
|
||||
- room type class cl2 exists
|
||||
- cl2 has code c1
|
||||
- cl2 has no properties
|
||||
ACT: - search room type class with code c1 and property p3
|
||||
- p3 have company m2
|
||||
POST: - only cl2 room type class found
|
||||
PRE: - room_type_class1 exists
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has property pms_property1
|
||||
- pms_property1 have the company company1
|
||||
- room type class room_type_class2 exists
|
||||
- room_type_class2 has code c1
|
||||
- room_type_class2 has no properties
|
||||
ACT: - search room type class with code c1 and property pms_property3
|
||||
- pms_property3 have company company2
|
||||
POST: - only room_type_class2 room type class found
|
||||
"""
|
||||
# ARRANGE
|
||||
# cl1
|
||||
# room_type_class1
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id])],
|
||||
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
|
||||
}
|
||||
)
|
||||
cl2 = self.env["pms.room.type.class"].create(
|
||||
room_type_class2 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl2",
|
||||
"code_class": "c1",
|
||||
@@ -338,38 +373,40 @@ class TestRoomTypeClassCodePropertyUniqueness(TestRoomTypeClass):
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p3.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property3.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
room_type_class.id, cl2.id, "Expected room type class not found"
|
||||
room_type_classes.id,
|
||||
room_type_class2.id,
|
||||
"Expected room type class not found",
|
||||
)
|
||||
|
||||
def test_multiple_case_04(self):
|
||||
"""
|
||||
PRE: - room type class cl1 exists
|
||||
- cl1 has code c1
|
||||
- cl1 has property p1
|
||||
- p1 have the company m1
|
||||
- room type cl2 exists
|
||||
- cl2 has code c1
|
||||
- cl2 has no properties
|
||||
ACT: - search room type class with code c1 and property p3
|
||||
- p3 have company m2
|
||||
PRE: - room_type_class1 exists
|
||||
- room_type_class1 has code c1
|
||||
- room_type_class1 has property pms_property1
|
||||
- pms_property1 have the company company1
|
||||
- room type room_type_class2 exists
|
||||
- room_type_class2 has code c1
|
||||
- room_type_class2 has no properties
|
||||
ACT: - search room type class with code c1 and property pms_property3
|
||||
- pms_property3 have company company2
|
||||
POST: - r2 room type class found
|
||||
"""
|
||||
# ARRANGE
|
||||
# cl1
|
||||
# room_type_class1
|
||||
self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl1",
|
||||
"name": "Room type class 1",
|
||||
"code_class": "c1",
|
||||
"pms_property_ids": [(6, 0, [self.p1.id])],
|
||||
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
|
||||
}
|
||||
)
|
||||
cl2 = self.env["pms.room.type.class"].create(
|
||||
room_type_class2 = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room type class cl2",
|
||||
"code_class": "c1",
|
||||
@@ -378,9 +415,11 @@ class TestRoomTypeClassCodePropertyUniqueness(TestRoomTypeClass):
|
||||
)
|
||||
|
||||
# ACT
|
||||
room_type_class = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.p3.id, "c1"
|
||||
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
|
||||
self.pms_property3.id, "c1"
|
||||
)
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(room_type_class.id, cl2.id, "Expected room type not found")
|
||||
self.assertEqual(
|
||||
room_type_classes.id, room_type_class2.id, "Expected room type not found"
|
||||
)
|
||||
|
||||
@@ -4,24 +4,13 @@ from freezegun import freeze_time
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
from .common import TestPms
|
||||
|
||||
|
||||
@freeze_time("2010-01-01")
|
||||
class TestPmsSaleChannel(TestHotel):
|
||||
def create_common_scenario(self):
|
||||
# create a property
|
||||
self.property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PROPERTY TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.env.ref("product.list0").id,
|
||||
}
|
||||
)
|
||||
|
||||
class TestPmsSaleChannel(TestPms):
|
||||
def test_not_agency_as_agency(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
PmsReservation = self.env["pms.reservation"]
|
||||
not_agency = self.env["res.partner"].create(
|
||||
{"name": "partner1", "is_agency": False}
|
||||
@@ -34,61 +23,59 @@ class TestPmsSaleChannel(TestHotel):
|
||||
"checkin": datetime.datetime.now(),
|
||||
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
|
||||
"agency_id": not_agency.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"pms_property_id": self.pms_property1.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_channel_type_id_only_directs(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
PmsReservation = self.env["pms.reservation"]
|
||||
PmsSaleChannel = self.env["pms.sale.channel"]
|
||||
# ACT
|
||||
salechannel = PmsSaleChannel.create({"channel_type": "direct"})
|
||||
sale_channel1 = PmsSaleChannel.create({"channel_type": "direct"})
|
||||
partner1 = self.env["res.partner"].create({"name": "partner1"})
|
||||
reservation = PmsReservation.create(
|
||||
reservation1 = PmsReservation.create(
|
||||
{
|
||||
"checkin": datetime.datetime.now(),
|
||||
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
|
||||
"channel_type_id": salechannel.id,
|
||||
"channel_type_id": sale_channel1.id,
|
||||
"partner_id": partner1.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"pms_property_id": self.pms_property1.id,
|
||||
}
|
||||
)
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
reservation.channel_type_id.channel_type,
|
||||
reservation1.channel_type_id.channel_type,
|
||||
"direct",
|
||||
"Sale channel is not direct",
|
||||
)
|
||||
|
||||
def test_agency_id_is_agency(self):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
PmsReservation = self.env["pms.reservation"]
|
||||
PmsSaleChannel = self.env["pms.sale.channel"]
|
||||
salechannel = PmsSaleChannel.create(
|
||||
sale_channel1 = PmsSaleChannel.create(
|
||||
{"name": "Test Indirect", "channel_type": "indirect"}
|
||||
)
|
||||
# ACT
|
||||
agency = self.env["res.partner"].create(
|
||||
agency1 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "partner1",
|
||||
"is_agency": True,
|
||||
"sale_channel_id": salechannel.id,
|
||||
"sale_channel_id": sale_channel1.id,
|
||||
}
|
||||
)
|
||||
reservation = PmsReservation.create(
|
||||
reservation1 = PmsReservation.create(
|
||||
{
|
||||
"checkin": datetime.datetime.now(),
|
||||
"checkout": datetime.datetime.now() + datetime.timedelta(days=3),
|
||||
"agency_id": agency.id,
|
||||
"pms_property_id": self.property.id,
|
||||
"agency_id": agency1.id,
|
||||
"pms_property_id": self.pms_property1.id,
|
||||
}
|
||||
)
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
reservation.agency_id.is_agency,
|
||||
reservation1.agency_id.is_agency,
|
||||
True,
|
||||
"Agency_id doesn't correspond to an agency",
|
||||
)
|
||||
@@ -97,13 +84,13 @@ class TestPmsSaleChannel(TestHotel):
|
||||
# ARRANGE
|
||||
PmsSaleChannel = self.env["pms.sale.channel"]
|
||||
# ACT
|
||||
saleChannel = PmsSaleChannel.create({"channel_type": "indirect"})
|
||||
agency = self.env["res.partner"].create(
|
||||
{"name": "example", "is_agency": True, "sale_channel_id": saleChannel.id}
|
||||
saleChannel1 = PmsSaleChannel.create({"channel_type": "indirect"})
|
||||
agency1 = self.env["res.partner"].create(
|
||||
{"name": "example", "is_agency": True, "sale_channel_id": saleChannel1.id}
|
||||
)
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
agency.sale_channel_id.channel_type,
|
||||
agency1.sale_channel_id.channel_type,
|
||||
"indirect",
|
||||
"An agency should be a indirect channel",
|
||||
)
|
||||
|
||||
@@ -3,12 +3,11 @@ import datetime
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
@freeze_time("1980-12-01")
|
||||
class TestPmsWizardMassiveChanges(TestHotel):
|
||||
class TestPmsWizardMassiveChanges(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# PRICELIST CREATION
|
||||
self.test_pricelist = self.env["product.pricelist"].create(
|
||||
@@ -19,9 +18,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
self.test_pricelist.flush()
|
||||
|
||||
# AVAILABILITY PLAN CREATION
|
||||
self.test_availability_plan = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create(
|
||||
self.test_availability_plan = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist.id])],
|
||||
@@ -29,12 +26,40 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
)
|
||||
self.test_availability_plan.flush()
|
||||
|
||||
# SEQUENCES
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
# PROPERTY CREATION (WITH DEFAULT PRICELIST AND AVAILABILITY PLAN
|
||||
self.test_property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
self.test_property.flush()
|
||||
@@ -50,7 +75,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
"name": "Single Test",
|
||||
"code_type": "SNG_Test",
|
||||
"default_code": "SNG_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
"list_price": 25.0,
|
||||
}
|
||||
@@ -62,7 +87,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
"name": "Double Test",
|
||||
"code_type": "DBL_Test",
|
||||
"default_code": "DBL_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
"list_price": 40.0,
|
||||
}
|
||||
@@ -676,7 +701,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
checkin = fields.date.today()
|
||||
checkout = fields.date.today() + datetime.timedelta(days=1)
|
||||
|
||||
self.env["pms.room.type.availability.rule"].create(
|
||||
self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"quota": 1,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
@@ -718,7 +743,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
checkin = fields.date.today()
|
||||
checkout = fields.date.today() + datetime.timedelta(days=1)
|
||||
|
||||
self.env["pms.room.type.availability.rule"].create(
|
||||
self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"min_stay": 3,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
|
||||
@@ -3,11 +3,10 @@ import datetime
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
|
||||
from .common import TestHotel
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPmsWizardMassiveChanges(TestHotel):
|
||||
class TestPmsWizardMassiveChanges(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# product.pricelist
|
||||
self.test_pricelist = self.env["product.pricelist"].create(
|
||||
@@ -15,21 +14,47 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
"name": "test pricelist 1",
|
||||
}
|
||||
)
|
||||
# pms.room.type.availability.plan
|
||||
self.test_availability_plan = self.env[
|
||||
"pms.room.type.availability.plan"
|
||||
].create(
|
||||
# pms.availability.plan
|
||||
self.test_availability_plan = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist.id])],
|
||||
}
|
||||
)
|
||||
# sequences
|
||||
self.folio_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Folio",
|
||||
"code": "pms.folio",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.reservation_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Reservation",
|
||||
"code": "pms.reservation",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
self.checkin_sequence = self.env["ir.sequence"].create(
|
||||
{
|
||||
"name": "PMS Checkin",
|
||||
"code": "pms.checkin.partner",
|
||||
"padding": 4,
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
}
|
||||
)
|
||||
# pms.property
|
||||
self.test_property = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "MY PMS TEST",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist.id,
|
||||
"folio_sequence_id": self.folio_sequence.id,
|
||||
"reservation_sequence_id": self.reservation_sequence.id,
|
||||
"checkin_sequence_id": self.checkin_sequence.id,
|
||||
}
|
||||
)
|
||||
# pms.room.type.class
|
||||
@@ -42,7 +67,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
"name": "Single Test",
|
||||
"code_type": "SNG_Test",
|
||||
"default_code": "SNG_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -51,7 +76,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
{
|
||||
"pms_property_ids": [self.test_property.id],
|
||||
"name": "Double Test",
|
||||
"code_type": "DBL_Test",
|
||||
"default_code": "DBL_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -240,7 +265,7 @@ class TestPmsWizardMassiveChanges(TestHotel):
|
||||
self.create_common_scenario()
|
||||
date = fields.date.today()
|
||||
initial_quota = 20
|
||||
self.env["pms.room.type.availability.rule"].create(
|
||||
self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"availability_plan_id": self.test_availability_plan.id,
|
||||
"room_type_id": self.test_room_type_double.id,
|
||||
|
||||
Reference in New Issue
Block a user