mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
* [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 <>
149 lines
5.1 KiB
Python
149 lines
5.1 KiB
Python
from odoo.exceptions import ValidationError
|
|
from odoo.tests import common
|
|
|
|
|
|
class TestPmsResUser(common.SavepointCase):
|
|
def create_common_scenario(self):
|
|
# create a room type availability
|
|
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(
|
|
{
|
|
"name": "Pms_Company1",
|
|
}
|
|
)
|
|
self.company_B = self.env["res.company"].create(
|
|
{
|
|
"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(
|
|
{
|
|
"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(
|
|
{
|
|
"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,
|
|
}
|
|
)
|
|
|
|
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,
|
|
}
|
|
)
|