[IMP]pms: Swap source and target complete reservations between dates

This commit is contained in:
Dario Lodeiros
2021-07-16 10:21:16 +02:00
parent 45f7248502
commit 3b2796a32f
2 changed files with 15 additions and 11 deletions

View File

@@ -260,8 +260,8 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms):
+------------+------+------+------+----+----+----+ +------------+------+------+------+----+----+----+
| room/date | 01 | 02 | 03 | 04 | 05 | 06 | | room/date | 01 | 02 | 03 | 04 | 05 | 06 |
+------------+------+------+------+----+----+----+ +------------+------+------+------+----+----+----+
| Double 101 | | r2 | r2 | | | | | Double 101 | r2 | r2 | r2 | | | |
| Double 102 | r2 | r1 | r1 | | | | | Double 102 | | r1 | r1 | | | |
+------------+------+------+------+----+----+----+ +------------+------+------+------+----+----+----+
""" """
# ARRANGE # ARRANGE
@@ -298,7 +298,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms):
# ASSERT # ASSERT
self.assertTrue( self.assertTrue(
r1.reservation_line_ids.room_id == self.room2 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): def test_swap_reservation_rooms_03(self):
@@ -364,6 +364,8 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms):
""" """
Check that two rooms from two different reservations are swapped Check that two rooms from two different reservations are swapped
correctly. correctly.
source: r1
target: r2
-------- --------
Initial state Initial state
@@ -416,13 +418,15 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms):
# ASSERT # ASSERT
self.assertTrue( self.assertTrue(
r1.reservation_line_ids.room_id == self.room2 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): def test_swap_reservation_rooms_05(self):
""" """
Check that two rooms from two different reservations are swapped Check that two rooms from two different reservations are swapped
correctly. correctly.
source: r2
target: r1
--------------- ---------------
Initial state Initial state
@@ -542,8 +546,8 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms):
+------------+------+------+------+----+----+----+ +------------+------+------+------+----+----+----+
| room/date | 01 | 02 | 03 | 04 | 05 | 06 | | room/date | 01 | 02 | 03 | 04 | 05 | 06 |
+------------+------+------+------+----+----+----+ +------------+------+------+------+----+----+----+
| Double 101 | r2 | | r2 | | | | | Double 101 | r2 | r2 | r2 | | | |
| Double 102 | r0 | r2 | r1 | | | | | Double 102 | r0 | | r1 | | | |
+------------+------+------+------+----+----+----+ +------------+------+------+------+----+----+----+
""" """
@@ -593,9 +597,7 @@ class TestPmsWizardSplitJoinSwapReservation(TestPms):
self.assertTrue( self.assertTrue(
r0.reservation_line_ids.room_id == self.room2 r0.reservation_line_ids.room_id == self.room2
and r1.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.room_id == self.room1
and r2.reservation_line_ids[2].room_id == self.room1
and r2.reservation_line_ids[1].room_id == self.room2
) )
def test_swap_reservation_rooms_gap_02(self): def test_swap_reservation_rooms_gap_02(self):

View File

@@ -52,7 +52,7 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
readonly=False, readonly=False,
store=True, store=True,
comodel_name="pms.reservation", comodel_name="pms.reservation",
compute="_compute_reservations", compute="_compute_reservation_ids",
) )
room_source = fields.Many2one( room_source = fields.Many2one(
string="Room Source", string="Room Source",
@@ -290,8 +290,10 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
line_room_target._compute_occupies_availability() line_room_target._compute_occupies_availability()
line_room_source._compute_occupies_availability() line_room_source._compute_occupies_availability()
else: elif line_room_source:
line_room_source.room_id = target line_room_source.room_id = target
elif line_room_target:
line_room_target.room_id = source
def action_split(self): def action_split(self):
for record in self: for record in self: