[FIX]pms: Fix check_date_order, check_checkin_datetime and cancelation_reason_late pms_reservation tests

This commit is contained in:
braisab
2021-07-16 11:08:21 +02:00
parent ac7d565e46
commit e29c085ffc
2 changed files with 10 additions and 14 deletions

View File

@@ -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",

View File

@@ -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,
}
)