Files
pms/pms/tests/test_pms_res_users.py
Sara 57d3ab0c8a 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>
2021-01-31 13:07:03 +01:00

92 lines
3.0 KiB
Python

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,
}
)