diff --git a/pms/tests/test_pms_wizard_split_join_swap_reservation.py b/pms/tests/test_pms_wizard_split_join_swap_reservation.py index cfe93b7d9..c1f6853ef 100644 --- a/pms/tests/test_pms_wizard_split_join_swap_reservation.py +++ b/pms/tests/test_pms_wizard_split_join_swap_reservation.py @@ -260,8 +260,8 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): +------------+------+------+------+----+----+----+ | room/date | 01 | 02 | 03 | 04 | 05 | 06 | +------------+------+------+------+----+----+----+ - | Double 101 | | r2 | r2 | | | | - | Double 102 | r2 | r1 | r1 | | | | + | Double 101 | r2 | r2 | r2 | | | | + | Double 102 | | r1 | r1 | | | | +------------+------+------+------+----+----+----+ """ # ARRANGE @@ -298,7 +298,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): # ASSERT self.assertTrue( r1.reservation_line_ids.room_id == self.room2 - and r2.reservation_line_ids[1:].room_id == self.room1 + and r2.reservation_line_ids.room_id == self.room1 ) def test_swap_reservation_rooms_03(self): @@ -364,6 +364,8 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): """ Check that two rooms from two different reservations are swapped correctly. + source: r1 + target: r2 -------- Initial state @@ -416,13 +418,15 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): # ASSERT self.assertTrue( r1.reservation_line_ids.room_id == self.room2 - and r2.reservation_line_ids[:1].room_id == self.room1 + and r2.reservation_line_ids.room_id == self.room1 ) def test_swap_reservation_rooms_05(self): """ Check that two rooms from two different reservations are swapped correctly. + source: r2 + target: r1 --------------- Initial state @@ -542,8 +546,8 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): +------------+------+------+------+----+----+----+ | room/date | 01 | 02 | 03 | 04 | 05 | 06 | +------------+------+------+------+----+----+----+ - | Double 101 | r2 | | r2 | | | | - | Double 102 | r0 | r2 | r1 | | | | + | Double 101 | r2 | r2 | r2 | | | | + | Double 102 | r0 | | r1 | | | | +------------+------+------+------+----+----+----+ """ @@ -593,9 +597,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms): self.assertTrue( r0.reservation_line_ids.room_id == self.room2 and r1.reservation_line_ids.room_id == self.room2 - and r2.reservation_line_ids[0].room_id == self.room1 - and r2.reservation_line_ids[2].room_id == self.room1 - and r2.reservation_line_ids[1].room_id == self.room2 + and r2.reservation_line_ids.room_id == self.room1 ) def test_swap_reservation_rooms_gap_02(self): diff --git a/pms/wizards/wizard_split_join_swap_reservation.py b/pms/wizards/wizard_split_join_swap_reservation.py index 53801a1e1..77cce5867 100644 --- a/pms/wizards/wizard_split_join_swap_reservation.py +++ b/pms/wizards/wizard_split_join_swap_reservation.py @@ -52,7 +52,7 @@ class ReservationSplitJoinSwapWizard(models.TransientModel): readonly=False, store=True, comodel_name="pms.reservation", - compute="_compute_reservations", + compute="_compute_reservation_ids", ) room_source = fields.Many2one( string="Room Source", @@ -290,8 +290,10 @@ class ReservationSplitJoinSwapWizard(models.TransientModel): line_room_target._compute_occupies_availability() line_room_source._compute_occupies_availability() - else: + elif line_room_source: line_room_source.room_id = target + elif line_room_target: + line_room_target.room_id = source def action_split(self): for record in self: