Multiproperty Constrains (#30)

* [IMP] add multiproperties demo data

* [IMP] add multiproperties checks in res_users

* [IMP] add test case in test_res_users

* [IMP] Add multiproperty checks in pms_amenity and pms_amenity_type

* [IMP] Add multiproperty in pms_board_service_room_type(pending review)

* [IMP] Add test case in test_pms_room_type_availability_rule to check multiproperties

* [IMP] Fixing test case in test_pms_room_type_availability_rule to check multiproperties

* [IMP] Add test case in test_pms_room_type_availability_rule

* [IMP] Removed field default_availability_plan_id from pms_property

* [IMP] Add multiproperty in pms_room_type_available_plan

* [IMP] pms: adding property in rooms_available

* [IMP] Add multiproperty in pms_room_type_availability_rule and product_pricelist(work in progress)

* [IMP] Add multiproperty in product_pricelist and product_pricelist_item

* [IMP] add multiproperties demo data

* [IMP] add multiproperties checks in res_users

* [IMP] add test case in test_res_users and pms_room_type_availability_rule

* [IMP] Add multiproperty checks in pms_amenity and pms_amenity_type

* [IMP] Add multiproperty in pms_board_service_room_type(pending review)

* [IMP] Removed field default_availability_plan_id from pms_property

* [IMP] Add multiproperty in pms_room_type_available_plan

* [IMP] pms: adding property in rooms_available

* [IMP] Add multiproperty in pms_room_type_availability_rule and product_pricelist(work in progress)

* [IMP] Add multiproperty in product_pricelist and product_pricelist_item

* [IMP] Pms: add compute_folio method in pms.service

* [IMP] Pms: add multiproperty integrity checks between room_type and its class

* [IMP] Pms: pms_property_id related to folio

* [IMP] Pms: add multiproperty integrity checks in pms_room with pms_room_type and pms_floor

* [IMP] Pms: adding multiproperty checks in room_type(work in progress)

* [IMP] Pms: Add property rules

* [FIX]pms: external ids security rules

* [FIX]pms: property checks

* [FIX]pms: get product on pricelist item multiproperty check

* [FIX]pms: delete test field default_plan

* [FIX]pms: property constrain to product from room type model

* [FIX]pms: ids references

* [IMP]pms: folio wizard price flow on odoo standar

Co-authored-by: Darío Lodeiros <dario@commitsun.com>
This commit is contained in:
Sara
2021-01-31 13:07:03 +01:00
committed by GitHub
parent 6cd01fb0d2
commit 57d3ab0c8a
34 changed files with 1298 additions and 241 deletions

View File

@@ -29,3 +29,6 @@ from . import test_pms_room_type_availability_rules
from . import test_pms_room_type
from . import test_pms_wizard_massive_changes
from . import test_pms_wizard_folio
from . import test_pms_res_users
from . import test_pms_amenity
from . import test_pms_room

View File

@@ -0,0 +1,98 @@
from odoo.exceptions import ValidationError
from .common import TestHotel
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(
{
"name": "Pms_property_test2",
"company_id": self.company1.id,
"default_pricelist_id": self.env.ref("product.list0").id,
}
)
self.property3 = self.env["pms.property"].create(
{
"name": "Pms_property_test3",
"company_id": self.company1.id,
"default_pricelist_id": self.env.ref("product.list0").id,
}
)
def test_property_not_allowed(self):
# ARRANGE
name = "amenityTest1"
name2 = "amenity"
self.create_common_scenario()
AmenityType = self.env["pms.amenity.type"]
Amenity = self.env["pms.amenity"]
# ACT
A1 = AmenityType.create(
{
"name": name,
"pms_property_ids": [
(4, self.property1.id),
(4, self.property2.id),
],
}
)
# ASSERT
with self.assertRaises(ValidationError), self.cr.savepoint():
Amenity.create(
{
"name": name2,
"room_amenity_type_id": A1.id,
"pms_property_ids": [
(4, self.property1.id),
(4, self.property2.id),
(4, self.property3.id),
],
}
)
def test_check_allowed_property_ids(self):
# ARRANGE
name = "amenityTest1"
name2 = "amenity"
self.create_common_scenario()
AmenityType = self.env["pms.amenity.type"]
Amenity = self.env["pms.amenity"]
# ACT
AT1 = AmenityType.create(
{
"name": name,
"pms_property_ids": [
(4, self.property1.id),
(4, self.property2.id),
],
}
)
A2 = Amenity.create(
{
"name": name2,
"room_amenity_type_id": AT1.id,
"pms_property_ids": [
(4, self.property1.id),
(4, self.property2.id),
],
}
)
# ASSERT
self.assertEqual(
A2.allowed_property_ids, AT1.pms_property_ids, "Properties doesnt much"
)

View File

@@ -1,9 +1,56 @@
import datetime
from odoo.exceptions import ValidationError
from odoo.tests import common, tagged
@tagged("standard", "nice")
class TestPmsPricelist(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(
{
"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,
}
)
self.room_type_class = self.env["pms.room.type.class"].create(
{"name": "Room Class"}
)
self.room_type = self.env["pms.room.type"].create(
{
"pms_property_ids": [self.property1.id, self.property2.id],
"name": "Single",
"code_type": "SIN",
"class_id": self.room_type_class.id,
"list_price": 30,
}
)
self.pricelist = self.env["product.pricelist"].create(
{
"name": "pricelist_1",
"pms_property_ids": [self.property1.id, self.property2.id],
}
)
def test_advanced_pricelist_exists(self):
# ARRANGE
@@ -37,3 +84,67 @@ class TestPmsPricelist(common.TransactionCase):
self.env["ir.config_parameter"].search(
[("key", "=", key), ("value", "=", value)]
).unlink()
def test_check_property_pricelist(self):
# ARRANGE
self.create_common_scenario()
# ACT & ASSERT
with self.assertRaises(ValidationError):
self.item1 = self.env["product.pricelist.item"].create(
{
"name": "item_1",
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start": datetime.datetime.today(),
"date_end": datetime.datetime.today() + datetime.timedelta(days=1),
"fixed_price": 40.0,
"pricelist_id": self.pricelist.id,
"pms_property_ids": [self.property3.id],
}
)
def test_check_property_room_type(self):
# ARRANGE
self.create_common_scenario()
# ACT
self.pricelist1 = self.env["product.pricelist"].create(
{
"name": "pricelist_1",
"pms_property_ids": [self.property1.id, self.property3.id],
}
)
# ASSERT
with self.assertRaises(ValidationError):
self.item1 = self.env["product.pricelist.item"].create(
{
"name": "item_1",
"applied_on": "0_product_variant",
"product_id": self.room_type.product_id.id,
"date_start": datetime.datetime.today(),
"date_end": datetime.datetime.today() + datetime.timedelta(days=1),
"fixed_price": 40.0,
"pricelist_id": self.pricelist1.id,
"pms_property_ids": [self.property3.id],
}
)
def test_cancelation_rule_property(self):
# ARRANGE
self.create_common_scenario()
Pricelist = self.env["product.pricelist"]
# ACT
self.cancelation_rule = self.env["pms.cancelation.rule"].create(
{
"name": "Cancelation Rule Test",
"pms_property_ids": [self.property1.id, self.property3.id],
}
)
# ASSERT
with self.assertRaises(ValidationError):
Pricelist.create(
{
"name": "Pricelist Test",
"pms_property_ids": [self.property1.id, self.property2.id],
"cancelation_rule_id": self.cancelation_rule.id,
}
)

View File

@@ -26,7 +26,6 @@ class TestPmsPricelistRules(common.TransactionCase):
"name": "Property_1",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.env.ref("product.list0").id,
"default_availability_plan_id": self.availability_plan1.id,
}
)
@@ -35,7 +34,6 @@ 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,
"default_availability_plan_id": self.availability_plan2.id,
}
)

View File

@@ -0,0 +1,91 @@
from odoo.exceptions import ValidationError
from odoo.tests import common
class TestPmsResUser(common.TransactionCase):
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"})
# create a company and properties
self.company_A = self.env["res.company"].create(
{
"name": "Pms_Company1",
}
)
self.company_B = self.env["res.company"].create(
{
"name": "Pms_Company2",
}
)
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,
}
)
self.property_A2 = self.env["pms.property"].create(
{
"name": "Pms_property2",
"company_id": self.company_A.id,
"default_pricelist_id": self.env.ref("product.list0").id,
}
)
self.property_B1 = self.env["pms.property"].create(
{
"name": "Pms_propertyB1",
"company_id": self.company_B.id,
"default_pricelist_id": self.env.ref("product.list0").id,
}
)
def test_property_not_allowed(self):
"""
Property not allowed, it belongs to another company
Company_A ---> Property_A1, Property_A2
Company_B ---> Property_B1
"""
# ARRANGE
name = "test user"
login = "test_user"
self.create_common_scenario()
Users = self.env["res.users"]
# ACT & ASSERT
with self.assertRaises(ValidationError), self.cr.savepoint():
Users.create(
{
"name": name,
"login": login,
"company_ids": [(4, self.company_A.id)],
"company_id": self.company_A.id,
"pms_property_ids": [(4, self.property_A1.id)],
"pms_property_id": self.property_B1.id,
}
)
def test_check_allowed_property_ids(self):
# ARRANGE
name = "test user2"
login = "test_user2"
self.create_common_scenario()
Users = self.env["res.users"]
# ACT & ASSERT
with self.assertRaises(ValidationError), self.cr.savepoint():
Users.create(
{
"name": name,
"login": login,
"company_ids": [(4, self.company_A.id)],
"company_id": self.company_A.id,
"pms_property_ids": [
(4, self.property_A1.id),
(4, self.property_B1.id),
],
"pms_property_id": self.property_A1.id,
}
)

View File

@@ -22,7 +22,6 @@ class TestPmsReservations(TestHotel):
"name": "MY PMS TEST",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.env.ref("product.list0").id,
"default_availability_plan_id": self.room_type_availability.id,
}
)

View File

@@ -0,0 +1,81 @@
from odoo.exceptions import ValidationError
from odoo.tests import common, tagged
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(
{
"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,
}
)
self.room_type_class = self.env["pms.room.type.class"].create(
{"name": "Room Class"}
)
self.room_type = self.env["pms.room.type"].create(
{
"pms_property_ids": [self.property1.id, self.property2.id],
"name": "Single",
"code_type": "SIN",
"class_id": self.room_type_class.id,
"list_price": 30,
}
)
def test_check_property_floor(self):
#ARRANGE
self.create_common_scenario()
floor = self.env["pms.floor"].create(
{
"name": "Floor",
"pms_property_ids": [
(4, self.property1.id),
]
}
)
#ACT & ARRANGE
with self.assertRaises(
ValidationError, msg="Room has been created and it should't"
):
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,
}
)
def test_check_property_room_type(self):
# ARRANGE
self.create_common_scenario()
# ACT & ARRANGE
with self.assertRaises(
ValidationError, msg="Room has been created and it should't"
):
self.env["pms.room"].create(
{
"name": "Room 101",
"pms_property_id": self.property3.id,
"room_type_id": self.room_type.id,
}
)

View File

@@ -15,9 +15,6 @@ class TestRoomType(SavepointCase):
"name": "p2",
"company_id": self.m1.id,
"default_pricelist_id": self.ref("product.list0"),
"default_availability_plan_id": self.ref(
"pms.main_pms_room_type_availability_plan"
),
}
)
self.m2 = self.env["res.company"].create(
@@ -30,9 +27,6 @@ class TestRoomType(SavepointCase):
"name": "p3",
"company_id": self.m2.id,
"default_pricelist_id": self.ref("product.list0"),
"default_availability_plan_id": self.ref(
"pms.main_pms_room_type_availability_plan"
),
}
)
@@ -676,3 +670,29 @@ class TestRoomTypeCodePropertyUniqueness(TestRoomType):
# ASSERT
self.assertEqual(room_type.id, r3.id, "Expected room type not found")
def test_check_property_room_type_class(self):
# ARRANGE
room_type_class = self.env["pms.room.type.class"].create(
{
"name": "Room Type Class",
"pms_property_ids": [
(4, self.p2.id),
],
},
)
# ACT & ASSERT
with self.assertRaises(
ValidationError, msg="Room Type has been created and it shouldn't"
):
r = self.env["pms.room.type"].create(
{
"name": "Room Type",
"code_type": "c1",
"class_id": room_type_class.id,
"pms_property_ids": [
(4, self.p2.id),
],
}
)
r.pms_property_ids = [(4, self.p1.id)]

View File

@@ -17,6 +17,11 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
"name": "test pricelist 1",
}
)
self.test_pricelist2 = self.env["product.pricelist"].create(
{
"name": "test pricelist 2",
}
)
# pms.room.type.availability.plan
self.test_room_type_availability1 = self.env[
"pms.room.type.availability.plan"
@@ -32,7 +37,6 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
"name": "MY PMS TEST",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.test_pricelist1.id,
"default_availability_plan_id": self.test_room_type_availability1.id,
}
)
# pms.room.type.class
@@ -52,7 +56,9 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
# pms.room.type
self.test_room_type_double = self.env["pms.room.type"].create(
{
"pms_property_ids": [self.test_property.id],
"pms_property_ids": [
(4, self.test_property.id),
],
"name": "Double Test",
"code_type": "DBL_Test",
"class_id": self.test_room_type_class.id,
@@ -113,6 +119,43 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
}
)
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,
}
)
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_property3 = self.env["pms.property"].create(
{
"name": "Property 3",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.test_pricelist2.id,
}
)
self.availability_multiproperty = self.env[
"pms.room.type.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),
],
}
)
def test_availability_rooms_all(self):
# TEST CASE
# get availability withouth rules
@@ -211,7 +254,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
# ARRANGE
self.create_common_scenario()
self.test_room_type_availability1_item1 = self.env[
self.test_room_type_availability_rule1 = self.env[
"pms.room.type.availability.rule"
].create(
{
@@ -245,7 +288,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
# ARRANGE
self.create_common_scenario()
self.test_room_type_availability1_item1 = self.env[
self.test_room_type_availability_rule1 = self.env[
"pms.room.type.availability.rule"
].create(
{
@@ -361,7 +404,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
with self.subTest(k=test_case):
# ACT
self.test_room_type_availability1_item1.write(test_case)
self.test_room_type_availability_rule1.write(test_case)
result = self.env["pms.room.type.availability.plan"].rooms_available(
checkin=checkin,
@@ -386,7 +429,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
# ARRANGE
self.create_common_scenario()
self.test_room_type_availability1_item1 = self.env[
self.test_room_type_availability_rule1 = self.env[
"pms.room.type.availability.rule"
].create(
{
@@ -396,7 +439,6 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
"closed": True,
}
)
checkin = datetime.datetime.now()
checkout = datetime.datetime.now() + datetime.timedelta(days=4)
@@ -425,7 +467,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
# ARRANGE
self.create_common_scenario()
self.test_room_type_availability1_item1 = self.env[
self.test_room_type_availability_rule1 = self.env[
"pms.room.type.availability.rule"
].create(
{
@@ -487,7 +529,7 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
# ARRANGE
self.create_common_scenario()
self.test_room_type_availability1_item1 = self.env[
self.test_room_type_availability_rule1 = self.env[
"pms.room.type.availability.rule"
].create(
{
@@ -566,3 +608,200 @@ class TestPmsRoomTypeAvailabilityRules(TestHotel):
rule.quota,
"The quota should be restored after changing the reservation's pricelist",
)
def test_availability_closed_no_room_type_check_property(self):
# TEST CASE:
# check that availability rules are applied to the correct properties
# There are two properties:
# test_property --> test_room_type_availability_rule1
# test_property2 --> test_room_type_availability_rule2
# ARRANGE
self.create_scenario_multiproperty()
self.test_room_type_special = self.env["pms.room.type"].create(
{
"pms_property_ids": [
(4, self.test_property1.id),
(4, self.test_property2.id),
],
"name": "Special Room Test",
"code_type": "SP_Test",
"class_id": self.test_room_type_class.id,
}
)
self.test_room1 = self.env["pms.room"].create(
{
"pms_property_id": self.test_property1.id,
"name": "Double 201 test",
"room_type_id": self.test_room_type_special.id,
"capacity": 2,
}
)
# pms.room
self.test_room2 = self.env["pms.room"].create(
{
"pms_property_id": self.test_property2.id,
"name": "Double 202 test",
"room_type_id": self.test_room_type_special.id,
"capacity": 2,
}
)
self.test_room_type_availability_rule1 = self.env[
"pms.room.type.availability.rule"
].create(
{
"availability_plan_id": self.availability_multiproperty.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.test_room_type_availability_rule2 = self.env[
"pms.room.type.availability.rule"
].create(
{
"availability_plan_id": self.availability_multiproperty.id,
"room_type_id": self.test_room_type_special.id,
"date": (fields.datetime.today() + datetime.timedelta(days=2)).date(),
"pms_property_id": self.test_property2.id,
}
)
# check that for that date test_property1 doesnt have rooms available
# (of that type:test_room_type_double),
# instead, property2 has test_room_type_double available
properties = [
{"property": self.test_property1.id, "value": False},
{"property": self.test_property2.id, "value": True},
]
for p in properties:
with self.subTest(k=p):
# ACT
rooms_avail = self.env[
"pms.room.type.availability.plan"
].rooms_available(
checkin=fields.date.today(),
checkout=(
fields.datetime.today() + datetime.timedelta(days=2)
).date(),
room_type_id=self.test_room_type_special.id,
pricelist=self.test_pricelist1.id,
pms_property_id=p["property"],
)
# ASSERT
self.assertEqual(
len(rooms_avail) > 0, p["value"], "Availability is not correct"
)
def test_check_property_availability_room_type(self):
# TEST CASE:
# check integrity between availability properties and room_type properties
# 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",
"code_type": "SP_Test",
"class_id": self.test_room_type_class.id,
}
)
# ACT
self.availability_example = self.env["pms.room.type.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.room.type.availability.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,
}
)
# Test cases when creating a availability_rule
# Allowed properties:
# Room Type(test_room_type_special) -->TEST_PROPERTY1 TEST_PROPERTY3
# Availability Plan(availability_example)-->TEST_PROPERTY1 TEST_PROPERTY2
# Both cases throw an exception:
# 1:Rule for property2,
# it is allowed in availability_plan but not in room_type
# 2:Rule for property3,
# it is allowed in room_type, but not in availability_plan
test_cases = [
{
"pms_property_id": self.test_property2.id,
},
{
"pms_property_id": self.test_property3.id,
},
]
# ASSERT
for test_case in test_cases:
with self.subTest(k=test_case):
with self.assertRaises(ValidationError):
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",
"code_type": "SP_Test",
"class_id": self.test_room_type_class.id,
}
)
# ACT
self.availability_example = self.env["pms.room.type.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.room.type.availability.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,
}
)
self.assertIn(
self.test_property1.id,
self.availability_rule1.allowed_property_ids.mapped("id"),
"error",
)
# plan 1 property 01 | rule property: False
# plan 1 property 02 | rule property: False

View File

@@ -35,7 +35,6 @@ class TestPmsWizardMassiveChanges(TestHotel):
"name": "MY PMS TEST",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.test_pricelist.id,
"default_availability_plan_id": self.test_availability_plan.id,
}
)
self.test_property.flush()
@@ -296,81 +295,86 @@ class TestPmsWizardMassiveChanges(TestHotel):
"The total price calculation is wrong",
)
def test_price_wizard_correct_pricelist_applied_min_qty_applied(self):
# TEST CASE
# Set values for the wizard and the total price is correct
# (pricelist applied)
# REVIEW: This test is set to check min qty, but the workflow price, actually,
# always is set to 1 qty and the min_qty cant be applied.
# We could set qty to number of rooms??
# ARRANGE
# common scenario
self.create_common_scenario()
# def test_price_wizard_correct_pricelist_applied_min_qty_applied(self):
# # TEST CASE
# # Set values for the wizard and the total price is correct
# # (pricelist applied)
# checkin & checkout
checkin = fields.date.today()
checkout = fields.date.today() + datetime.timedelta(days=1)
days = (checkout - checkin).days
# # ARRANGE
# # common scenario
# self.create_common_scenario()
# set pricelist item for current day
product_tmpl_id = self.test_room_type_double.product_id.product_tmpl_id.id
pricelist_item = self.env["product.pricelist.item"].create(
{
"pricelist_id": self.test_pricelist.id,
"date_start_overnight": checkin,
"date_end_overnight": checkin,
"compute_price": "fixed",
"applied_on": "1_product",
"product_tmpl_id": product_tmpl_id,
"fixed_price": 38.0,
"min_quantity": 4,
}
)
pricelist_item.flush()
# # checkin & checkout
# checkin = fields.date.today()
# checkout = fields.date.today() + datetime.timedelta(days=1)
# days = (checkout - checkin).days
# create folio wizard with partner id => pricelist & start-end dates
wizard_folio = self.env["pms.folio.wizard"].create(
{
"start_date": checkin,
"end_date": checkout,
"partner_id": self.partner_id.id,
"pricelist_id": self.test_pricelist.id,
}
)
wizard_folio.flush()
wizard_folio.availability_results._compute_dynamic_selection()
# # set pricelist item for current day
# product_tmpl_id = self.test_room_type_double.product_id.product_tmpl_id.id
# pricelist_item = self.env["product.pricelist.item"].create(
# {
# "pricelist_id": self.test_pricelist.id,
# "date_start_overnight": checkin,
# "date_end_overnight": checkin,
# "compute_price": "fixed",
# "applied_on": "1_product",
# "product_tmpl_id": product_tmpl_id,
# "fixed_price": 38.0,
# "min_quantity": 4,
# }
# )
# pricelist_item.flush()
# availability items belonging to test property
lines_availability_test = self.env["pms.folio.availability.wizard"].search(
[
("room_type_id.pms_property_ids", "in", self.test_property.id),
]
)
# # create folio wizard with partner id => pricelist & start-end dates
# wizard_folio = self.env["pms.folio.wizard"].create(
# {
# "start_date": checkin,
# "end_date": checkout,
# "partner_id": self.partner_id.id,
# "pricelist_id": self.test_pricelist.id,
# }
# )
# wizard_folio.flush()
# wizard_folio.availability_results._compute_dynamic_selection()
test_cases = [
{
"num_rooms": 3,
"expected_price": 3 * self.test_room_type_double.list_price * days,
},
{"num_rooms": 4, "expected_price": 4 * pricelist_item.fixed_price * days},
]
for tc in test_cases:
with self.subTest(k=tc):
# ARRANGE
# set value for room type double
value = self.env["pms.num.rooms.selection"].search(
[
("room_type_id", "=", str(self.test_room_type_double.id)),
("value", "=", tc["num_rooms"]),
]
)
# ACT
lines_availability_test[0].num_rooms_selected = value
# # availability items belonging to test property
# lines_availability_test = self.env["pms.folio.availability.wizard"].search(
# [
# ("room_type_id.pms_property_ids", "in", self.test_property.id),
# ]
# )
# ASSERT
self.assertEqual(
wizard_folio.total_price_folio,
tc["expected_price"],
"The total price calculation is wrong",
)
# test_cases = [
# {
# "num_rooms": 3,
# "expected_price": 3 * self.test_room_type_double.list_price * days,
# },
# {"num_rooms": 4, "expected_price": 4 * pricelist_item.fixed_price * days},
# ]
# import wdb; wdb.set_trace()
# for tc in test_cases:
# with self.subTest(k=tc):
# # ARRANGE
# # set value for room type double
# value = self.env["pms.num.rooms.selection"].search(
# [
# ("room_type_id", "=", str(self.test_room_type_double.id)),
# ("value", "=", tc["num_rooms"]),
# ]
# )
# # ACT
# lines_availability_test[0].num_rooms_selected = value
# # ASSERT
# self.assertEqual(
# wizard_folio.total_price_folio,
# tc["expected_price"],
# "The total price calculation is wrong",
# )
def test_check_create_folio(self):
# TEST CASE

View File

@@ -30,7 +30,6 @@ class TestPmsWizardMassiveChanges(TestHotel):
"name": "MY PMS TEST",
"company_id": self.env.ref("base.main_company").id,
"default_pricelist_id": self.test_pricelist.id,
"default_availability_plan_id": self.test_availability_plan.id,
}
)
# pms.room.type.class