From e29c085ffcc1267e73b9eebd37bc11c8a99be1dc Mon Sep 17 00:00:00 2001 From: braisab Date: Fri, 16 Jul 2021 11:08:21 +0200 Subject: [PATCH] [FIX]pms: Fix check_date_order, check_checkin_datetime and cancelation_reason_late pms_reservation tests --- pms/models/pms_reservation.py | 8 ++------ pms/tests/test_pms_reservation.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index 4df0b83cc..0d8ffdc5f 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -595,18 +595,14 @@ class PmsReservation(models.Model): compute="_compute_services_discount", tracking=True, ) - date_order = fields.Date( + date_order = fields.Datetime( string="Date Order", help="Order date of reservation", - compute="_compute_date_order", + default=fields.Datetime.now, store=True, readonly=False, ) - def _compute_date_order(self): - for record in self: - record.date_order = datetime.datetime.today() - @api.depends( "checkin", "checkout", diff --git a/pms/tests/test_pms_reservation.py b/pms/tests/test_pms_reservation.py index 179534974..a5fbcca04 100644 --- a/pms/tests/test_pms_reservation.py +++ b/pms/tests/test_pms_reservation.py @@ -1731,7 +1731,7 @@ class TestPmsReservations(TestPms): with self.assertRaises(UserError): self.reservation_test.write(test_case) - def _test_check_date_order(self): + def test_check_date_order(self): """ Check that the date order of a reservation is correct. --------------- @@ -1753,7 +1753,7 @@ class TestPmsReservations(TestPms): "Date Order isn't correct", ) - def _test_check_checkin_datetime(self): + def test_check_checkin_datetime(self): """ Check that the checkin datetime of a reservation is correct. ------------------ @@ -1770,7 +1770,7 @@ class TestPmsReservations(TestPms): ) r = reservation.checkin checkin_expected = datetime.datetime(r.year, r.month, r.day, 14, 00) - # checkin_expected = checkin_expected.astimezone(self.property.tz.value) + checkin_expected = self.pms_property1.date_property_timezone(checkin_expected) self.assertEqual( str(reservation.checkin_datetime), @@ -2305,14 +2305,14 @@ class TestPmsReservations(TestPms): reservation.cancelled_reason, "intime", "Cancelled reason must be 'intime'" ) - def _test_cancelation_reason_late(self): + def test_cancelation_reason_late(self): """ Check that if a reservation is canceled outside the cancellation period, the canceled_reason field of the reservation must be "late" . --------- - Create a cancellation rule with the days_late = 3 field. - A reservation is created with a check-in date for tomorrow and the - action_cancel method is launched. As the reservation was canceled + Create a cancellation rule with the field days_intime = 3. + A reservation is created with a checkin date for tomorrow and the + action_cancel() method is launched. As the reservation was canceled after the deadline, the canceled_reason field must be late """ Pricelist = self.env["product.pricelist"] @@ -2320,7 +2320,7 @@ class TestPmsReservations(TestPms): { "name": "Cancelation Rule Test", "pms_property_ids": [self.pms_property1.id], - "days_late": 3, + "days_intime": 3, } )