From f3d4b7545bac7037bf0ebc885e1bb1d8fa6b488d Mon Sep 17 00:00:00 2001 From: Eric Antones Date: Tue, 16 Feb 2021 17:23:51 +0100 Subject: [PATCH] [14.0][FIX] pms: minor fixes (#51) * [FIX] pms: constraint raised when there's no other room type with the same alternate key * [FIX] pms: required default_pricelist_id field readded in property view * [FIX] pms: pre-commit black error --- pms/models/pms_room_type.py | 8 ++++---- pms/tests/test_pms_reservation.py | 10 ++++------ pms/views/pms_property_views.xml | 7 +++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pms/models/pms_room_type.py b/pms/models/pms_room_type.py index 574d25336..7489b35c1 100644 --- a/pms/models/pms_room_type.py +++ b/pms/models/pms_room_type.py @@ -144,10 +144,10 @@ class PmsRoomType(models.Model): raise ValidationError(msg) else: for pms_property in rec.pms_property_ids: - if ( - rec.get_unique_by_property_code(pms_property.id, rec.code_type) - != rec - ): + other = rec.get_unique_by_property_code( + pms_property.id, rec.code_type + ) + if other and other != rec: raise ValidationError(msg) # ORM Overrides diff --git a/pms/tests/test_pms_reservation.py b/pms/tests/test_pms_reservation.py index 0f8e980c0..7e0b671f7 100644 --- a/pms/tests/test_pms_reservation.py +++ b/pms/tests/test_pms_reservation.py @@ -722,9 +722,7 @@ class TestPmsReservations(TestHotel): # ACT res.action_cancel() # ASSERT - self.assertEqual(res.state, - 'cancelled', - "The reservation should be cancelled") + self.assertEqual(res.state, "cancelled", "The reservation should be cancelled") @freeze_time("1981-11-01") def test_reservation_action_checkout(self): @@ -761,6 +759,6 @@ class TestPmsReservations(TestHotel): r1.action_reservation_checkout() # ASSERT - self.assertEqual(r1.state, - "done", - "The reservation status should be done after checkout.") + self.assertEqual( + r1.state, "done", "The reservation status should be done after checkout." + ) diff --git a/pms/views/pms_property_views.xml b/pms/views/pms_property_views.xml index e5c2b647d..802c0fa8f 100644 --- a/pms/views/pms_property_views.xml +++ b/pms/views/pms_property_views.xml @@ -18,6 +18,13 @@ + + +