mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD]multi_pms_properties (#66)
* [WIP]pms: models check_pms_property * [WIP][IMP+REF] multi_pms_properties: refactor and added test skeleton * [FIX] inherit create models * [ADD] room multiproperty check * [ADD] room multiproperty check * [IMP] Multiproperty checks in pms models * [IMP] Fix Multiproperty checks in pms models * [IMP] Add multiproperty domain in multi_pms_properties module * [IMP] Fix multiproperty checks in pms tests * [IMP] Fix multiproperty checks logic * [IMP] Auto Domains * [IMP] availability property results, domain preferred_room_id * [IMP] model domain properties * [ADD] pms multiproperty depends * [IMP] models and views multiproperty checks * [FIX] Multiple rebase multiproperty fixes * [ADD] Readme * [ADD] Company - multiproperty checks * [ADD] travis server wide modules multiproperty * [FIX] travis conf load * [FIX] travis conf load2 * [FIX] travis conf load2 Co-authored-by: Eric Antones <eantones@nuobit.com> Co-authored-by: Sara Lago <saralago126@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
from .common import TestPms
|
||||
|
||||
@@ -51,7 +51,7 @@ class TestPmsAmenity(TestPms):
|
||||
}
|
||||
)
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||
with self.assertRaises(UserError), self.cr.savepoint():
|
||||
Amenity.create(
|
||||
{
|
||||
"name": "TestAmenity1",
|
||||
@@ -69,115 +69,3 @@ class TestPmsAmenity(TestPms):
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
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
|
||||
AmenityType = self.env["pms.amenity.type"]
|
||||
Amenity = self.env["pms.amenity"]
|
||||
amenity_type1 = AmenityType.create(
|
||||
{
|
||||
"name": "TestAmenityType1",
|
||||
"pms_property_ids": [
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[
|
||||
self.pms_property1.id,
|
||||
self.pms_property2.id,
|
||||
self.pms_property3.id,
|
||||
],
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
amenity1 = 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(
|
||||
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
|
||||
with self.assertRaises(ValidationError):
|
||||
amenity_type1.pms_property_ids = [
|
||||
(
|
||||
6,
|
||||
0,
|
||||
[self.pms_property1.id, self.pms_property2.id],
|
||||
)
|
||||
]
|
||||
amenity_type1.flush()
|
||||
|
||||
@@ -3,24 +3,42 @@ import datetime
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
@freeze_time("1980-01-01")
|
||||
class TestPmsRoomTypeAvailabilityRules(common.SavepointCase):
|
||||
def create_common_scenario(self):
|
||||
# product.pricelist
|
||||
self.test_pricelist1 = self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "test pricelist 1",
|
||||
}
|
||||
)
|
||||
self.test_pricelist2 = self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "test pricelist 2",
|
||||
}
|
||||
)
|
||||
self.test_property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property 1",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist2.id,
|
||||
}
|
||||
)
|
||||
self.test_property2 = self.env["pms.property"].create(
|
||||
{
|
||||
"name": "Property 2",
|
||||
"company_id": self.env.ref("base.main_company").id,
|
||||
"default_pricelist_id": self.test_pricelist2.id,
|
||||
}
|
||||
)
|
||||
self.test_pricelist1 = self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "test pricelist 1",
|
||||
"pms_property_ids": [
|
||||
(4, self.test_property1.id),
|
||||
(4, self.test_property2.id),
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# pms.availability.plan
|
||||
self.test_room_type_availability1 = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
@@ -148,27 +166,6 @@ class TestPmsRoomTypeAvailabilityRules(common.SavepointCase):
|
||||
|
||||
def create_scenario_multiproperty(self):
|
||||
self.create_common_scenario()
|
||||
|
||||
self.test_property1 = self.env["pms.property"].create(
|
||||
{
|
||||
"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(
|
||||
{
|
||||
"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(
|
||||
{
|
||||
"name": "Property 3",
|
||||
@@ -583,6 +580,11 @@ class TestPmsRoomTypeAvailabilityRules(common.SavepointCase):
|
||||
"pms_property_id": self.test_property.id,
|
||||
}
|
||||
)
|
||||
self.test_pricelist1.pms_property_ids = [
|
||||
(4, self.test_property1.id),
|
||||
(4, self.test_property2.id),
|
||||
(4, self.test_property.id),
|
||||
]
|
||||
r1 = self.env["pms.reservation"].create(
|
||||
{
|
||||
"pms_property_id": self.test_property.id,
|
||||
@@ -627,6 +629,11 @@ class TestPmsRoomTypeAvailabilityRules(common.SavepointCase):
|
||||
"name": "test pricelist 2",
|
||||
}
|
||||
)
|
||||
self.test_pricelist1.pms_property_ids = [
|
||||
(4, self.test_property1.id),
|
||||
(4, self.test_property2.id),
|
||||
(4, self.test_property.id),
|
||||
]
|
||||
rule = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"availability_plan_id": self.test_room_type_availability1.id,
|
||||
@@ -801,52 +808,7 @@ class TestPmsRoomTypeAvailabilityRules(common.SavepointCase):
|
||||
# ASSERT
|
||||
for test_case in test_cases:
|
||||
with self.subTest(k=test_case):
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.availability_rule1.pms_property_id = test_case[
|
||||
"pms_property_id"
|
||||
]
|
||||
|
||||
def test_compute_allowed_property_ids(self):
|
||||
# TEST CASE:
|
||||
#
|
||||
|
||||
# ARRANGE
|
||||
self.create_scenario_multiproperty()
|
||||
# create new room_type
|
||||
self.test_room_type_special = self.env["pms.room.type"].create(
|
||||
{
|
||||
"pms_property_ids": [
|
||||
(4, self.test_property1.id),
|
||||
(4, self.test_property3.id),
|
||||
],
|
||||
"name": "Special Room Test",
|
||||
"default_code": "SP_Test",
|
||||
"class_id": self.test_room_type_class.id,
|
||||
}
|
||||
)
|
||||
# ACT
|
||||
self.availability_example = self.env["pms.availability.plan"].create(
|
||||
{
|
||||
"name": "Availability plan for TEST",
|
||||
"pms_pricelist_ids": [(6, 0, [self.test_pricelist1.id])],
|
||||
"pms_property_ids": [
|
||||
(4, self.test_property1.id),
|
||||
(4, self.test_property2.id),
|
||||
],
|
||||
}
|
||||
)
|
||||
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,
|
||||
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
|
||||
"closed": True,
|
||||
"pms_property_id": self.test_property1.id,
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
self.test_property1.id,
|
||||
self.availability_rule1.allowed_property_ids.mapped("id"),
|
||||
"error",
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class TestPmsBoardService(common.SavepointCase):
|
||||
"default_code": "CB",
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
board_service_line = self.board_service_line = self.env[
|
||||
"pms.board.service.line"
|
||||
].create(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
@@ -57,19 +57,21 @@ class TestPmsBoardServiceRoomTypeLine(common.SavepointCase):
|
||||
{
|
||||
"name": "Board Service",
|
||||
"default_code": "CB",
|
||||
"pms_property_ids": self.property1,
|
||||
}
|
||||
)
|
||||
self.room_type_class = self.env["pms.room.type.class"].create(
|
||||
{
|
||||
"name": "Room Type Class",
|
||||
"pms_property_ids": self.property1,
|
||||
"default_code": "SIN1",
|
||||
"pms_property_ids": self.property1,
|
||||
}
|
||||
)
|
||||
self.room_type = self.env["pms.room.type"].create(
|
||||
{
|
||||
"name": "Room Type",
|
||||
"default_code": "Type1",
|
||||
"pms_property_ids": self.property1,
|
||||
"class_id": self.room_type_class.id,
|
||||
}
|
||||
)
|
||||
@@ -84,8 +86,7 @@ class TestPmsBoardServiceRoomTypeLine(common.SavepointCase):
|
||||
self.product = self.env["product.product"].create(
|
||||
{"name": "Product", "pms_property_ids": self.property2}
|
||||
)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.env["pms.board.service.room.type.line"].create(
|
||||
{
|
||||
"pms_board_service_room_type_id": self.board_service_room_type.id,
|
||||
|
||||
@@ -3,7 +3,7 @@ import datetime
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import common
|
||||
|
||||
freeze_time("2000-02-02")
|
||||
@@ -279,7 +279,7 @@ class TestPmsFolio(common.SavepointCase):
|
||||
}
|
||||
)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.env["pms.folio"].create(
|
||||
{
|
||||
"pms_property_id": self.property3.id,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import datetime
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.tests import common, tagged
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ class TestPmsPricelist(common.SavepointCase):
|
||||
# ARRANGE
|
||||
self.create_common_scenario()
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.item1 = self.env["product.pricelist.item"].create(
|
||||
{
|
||||
"name": "item_1",
|
||||
@@ -149,7 +149,7 @@ class TestPmsPricelist(common.SavepointCase):
|
||||
}
|
||||
)
|
||||
# ASSERT
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.item1 = self.env["product.pricelist.item"].create(
|
||||
{
|
||||
"name": "item_1",
|
||||
@@ -175,7 +175,7 @@ class TestPmsPricelist(common.SavepointCase):
|
||||
}
|
||||
)
|
||||
# ASSERT
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
Pricelist.create(
|
||||
{
|
||||
"name": "Pricelist Test",
|
||||
@@ -189,7 +189,7 @@ class TestPmsPricelist(common.SavepointCase):
|
||||
self.availability_plan = self.env["pms.availability.plan"].create(
|
||||
{"name": "Availability Plan", "pms_property_ids": [self.property1.id]}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.env["product.pricelist"].create(
|
||||
{
|
||||
"name": "Pricelist",
|
||||
|
||||
@@ -122,7 +122,6 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"partner_id": self.partner1.id,
|
||||
}
|
||||
)
|
||||
|
||||
# ACT
|
||||
n_days = (reservation.checkout - reservation.checkin).days
|
||||
expected_price = self.room.room_type_id.list_price * n_days
|
||||
@@ -147,7 +146,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
# 5. id
|
||||
# - tie
|
||||
# - no [date_start|date_end|date_start_overnight|date_end_overnight]
|
||||
|
||||
properties = self.room_type.product_id.pms_property_ids.ids
|
||||
test_cases = [
|
||||
{
|
||||
"name": "sorting applied_on",
|
||||
@@ -164,6 +163,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"applied_on": "0_product_variant",
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"fixed_price": 50.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -171,6 +171,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"product_tmpl_id": self.product_template.id,
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -186,6 +187,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=2),
|
||||
"fixed_price": 60.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -195,6 +197,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=1),
|
||||
"fixed_price": 50.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -204,6 +207,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=3),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -219,6 +223,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end_overnight": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=6),
|
||||
"fixed_price": 60.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -228,6 +233,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end_overnight": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=10),
|
||||
"fixed_price": 50.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -237,6 +243,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end_overnight": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=3),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -249,6 +256,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"applied_on": "0_product_variant",
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"fixed_price": 60.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -275,18 +283,21 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"applied_on": "0_product_variant",
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"fixed_price": 60.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
"applied_on": "0_product_variant",
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"fixed_price": 50.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
"applied_on": "0_product_variant",
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -302,6 +313,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=2),
|
||||
"fixed_price": 60.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -312,6 +324,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=1),
|
||||
"fixed_price": 50.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -327,6 +340,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=10),
|
||||
"fixed_price": 120.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -336,6 +350,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end_overnight": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=3),
|
||||
"fixed_price": 50.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -351,6 +366,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end_overnight": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=3),
|
||||
"fixed_price": 120.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -376,6 +392,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end_overnight": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=3),
|
||||
"fixed_price": 120.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
{
|
||||
"pricelist_id": self.pricelist.id,
|
||||
@@ -432,6 +449,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_end": datetime.datetime.now()
|
||||
+ datetime.timedelta(days=1),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -445,6 +463,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"date_start": datetime.datetime.now(),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -458,6 +477,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"date_end_overnight": datetime.datetime.now(),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -471,6 +491,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"product_id": self.room_type.product_id.id,
|
||||
"date_start_overnight": datetime.datetime.now(),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -485,6 +506,7 @@ class TestPmsPricelistRules(common.SavepointCase):
|
||||
"date_start_overnight": datetime.datetime.now(),
|
||||
"date_end_overnight": datetime.datetime.now(),
|
||||
"fixed_price": 40.0,
|
||||
"pms_property_ids": properties,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -951,7 +951,7 @@ class TestPmsReservations(common.SavepointCase):
|
||||
|
||||
for test_case in test_cases:
|
||||
with self.subTest(k=test_case):
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.reservation_test.write(test_case)
|
||||
|
||||
@freeze_time("1950-11-01")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from psycopg2 import IntegrityError
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import mute_logger
|
||||
|
||||
from .common import TestPms
|
||||
@@ -38,9 +38,7 @@ class TestPmsRoom(TestPms):
|
||||
}
|
||||
)
|
||||
# ACT & ARRANGE
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="Room has been created and it should't"
|
||||
):
|
||||
with self.assertRaises(UserError, msg="Room has been created and it should't"):
|
||||
self.env["pms.room"].create(
|
||||
{
|
||||
"name": "Room 101",
|
||||
@@ -60,9 +58,7 @@ class TestPmsRoom(TestPms):
|
||||
}
|
||||
)
|
||||
# ACT & ARRANGE
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="Room has been created and it should't"
|
||||
):
|
||||
with self.assertRaises(UserError, msg="Room has been created and it should't"):
|
||||
self.env["pms.room"].create(
|
||||
{
|
||||
"name": "Room 101",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2021 Eric Antones <eantones@nuobit.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
from .common import TestPms
|
||||
|
||||
@@ -68,7 +68,7 @@ class TestRoomType(TestPms):
|
||||
"""
|
||||
# ARRANGE & ACT & ASSERT
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="The room type has been created and it shouldn't"
|
||||
UserError, msg="The room type has been created and it shouldn't"
|
||||
):
|
||||
# room_type1
|
||||
self.env["pms.room.type"].create(
|
||||
@@ -95,7 +95,7 @@ class TestRoomType(TestPms):
|
||||
"""
|
||||
# ARRANGE & ACT & ASSERT
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="The room type has been created and it shouldn't"
|
||||
UserError, msg="The room type has been created and it shouldn't"
|
||||
):
|
||||
# room_type1
|
||||
self.env["pms.room.type"].create(
|
||||
@@ -728,7 +728,7 @@ class TestRoomType(TestPms):
|
||||
)
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(
|
||||
ValidationError, msg="Room Type has been created and it shouldn't"
|
||||
UserError, msg="Room Type has been created and it shouldn't"
|
||||
):
|
||||
room_type1 = self.env["pms.room.type"].create(
|
||||
{
|
||||
@@ -776,7 +776,7 @@ class TestRoomType(TestPms):
|
||||
self.amenity1 = self.env["pms.amenity"].create(
|
||||
{"name": "Amenity", "pms_property_ids": self.pms_property1}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
self.env["pms.room.type"].create(
|
||||
{
|
||||
"name": "Room Type",
|
||||
|
||||
@@ -268,7 +268,7 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
|
||||
expected_price_total = days * price_today * num_double_rooms
|
||||
|
||||
# set pricelist item for current day
|
||||
product_tmpl_id = self.test_room_type_double.product_id.product_tmpl_id.id
|
||||
product_tmpl = self.test_room_type_double.product_id.product_tmpl_id
|
||||
pricelist_item = self.env["product.pricelist.item"].create(
|
||||
{
|
||||
"pricelist_id": self.test_pricelist.id,
|
||||
@@ -276,9 +276,10 @@ class TestPmsWizardMassiveChanges(common.SavepointCase):
|
||||
"date_end_overnight": checkin,
|
||||
"compute_price": "fixed",
|
||||
"applied_on": "1_product",
|
||||
"product_tmpl_id": product_tmpl_id,
|
||||
"product_tmpl_id": product_tmpl.id,
|
||||
"fixed_price": price_today,
|
||||
"min_quantity": 0,
|
||||
"pms_property_ids": product_tmpl.pms_property_ids.ids,
|
||||
}
|
||||
)
|
||||
pricelist_item.flush()
|
||||
|
||||
Reference in New Issue
Block a user