mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Check persons Onboard reservation
This commit is contained in:
@@ -244,7 +244,7 @@
|
||||
<field name="room_type_id" ref="pms_room_type_3" />
|
||||
<field name="adults">2</field>
|
||||
<field name="children">1</field>
|
||||
<field name="state">onboard</field>
|
||||
<field name="state">confirm</field>
|
||||
<field name="checkin" eval="DateTime.today()" />
|
||||
<field name="checkout" eval="DateTime.today() + timedelta(4)" />
|
||||
<field name="board_service_room_id" ref="pms_board_service_room_2" />
|
||||
|
||||
@@ -129,7 +129,7 @@ class PmsCheckinPartner(models.Model):
|
||||
if reservation_id:
|
||||
reservation = self.env["pms.reservation"].browse(reservation_id)
|
||||
draft_checkins = reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state in ("draft")
|
||||
lambda c: c.state == "draft"
|
||||
)
|
||||
if len(draft_checkins) > 0 and vals.get("partner_id"):
|
||||
draft_checkins[0].sudo().unlink()
|
||||
|
||||
@@ -572,7 +572,7 @@ class PmsReservation(models.Model):
|
||||
lambda c: c.state in ("precheckin", "onboard", "done")
|
||||
)
|
||||
unassigned_checkins = reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state in ("draft")
|
||||
lambda c: c.state == "draft"
|
||||
)
|
||||
leftover_unassigneds_count = (
|
||||
len(assigned_checkins) + len(unassigned_checkins) - reservation.adults
|
||||
@@ -626,7 +626,7 @@ class PmsReservation(models.Model):
|
||||
def _compute_pending_checkin_data(self):
|
||||
for reservation in self:
|
||||
reservation.pending_checkin_data = len(
|
||||
reservation.checkin_partner_ids.filtered(lambda c: c.state in ("draft"))
|
||||
reservation.checkin_partner_ids.filtered(lambda c: c.state == "draft")
|
||||
)
|
||||
|
||||
@api.depends("pending_checkin_data")
|
||||
@@ -718,7 +718,7 @@ class PmsReservation(models.Model):
|
||||
"Product Unit of Measure"
|
||||
)
|
||||
for line in self:
|
||||
if line.state in ("draft"):
|
||||
if line.state == "draft":
|
||||
line.invoice_status = "no"
|
||||
elif not float_is_zero(line.qty_to_invoice, precision_digits=precision):
|
||||
line.invoice_status = "to invoice"
|
||||
@@ -857,7 +857,9 @@ class PmsReservation(models.Model):
|
||||
def _max_checkin_partner_ids(self):
|
||||
for record in self:
|
||||
if len(record.checkin_partner_ids) > record.adults:
|
||||
raise models.ValidationError(_("The room already is completed"))
|
||||
raise models.ValidationError(
|
||||
_("The room already is completed (%s)", record.name)
|
||||
)
|
||||
|
||||
@api.constrains("adults")
|
||||
def _check_adults(self):
|
||||
@@ -870,9 +872,23 @@ class PmsReservation(models.Model):
|
||||
len(extra_bed)
|
||||
):
|
||||
raise ValidationError(
|
||||
_("Persons can't be higher than room capacity")
|
||||
_(
|
||||
"Persons can't be higher than room capacity (%s)",
|
||||
record.name,
|
||||
)
|
||||
)
|
||||
|
||||
@api.constrains("state")
|
||||
def _check_onboard_reservation(self):
|
||||
for record in self:
|
||||
if (
|
||||
not record.checkin_partner_ids.filtered(lambda c: c.state == "onboard")
|
||||
and record.state == "onboard"
|
||||
):
|
||||
raise ValidationError(
|
||||
_("No person from reserve %s has arrived", record.name)
|
||||
)
|
||||
|
||||
# @api.constrains("reservation_type", "partner_id")
|
||||
# def _check_partner_reservation(self):
|
||||
# for reservation in self:
|
||||
@@ -1050,7 +1066,7 @@ class PmsReservation(models.Model):
|
||||
def autocheckout(self):
|
||||
reservations = self.env["pms.reservation"].search(
|
||||
[
|
||||
("state", "not in", ("done", "cancelled")),
|
||||
("state", "not in", ["done", "cancelled"]),
|
||||
("checkout", "<", fields.Date.today()),
|
||||
]
|
||||
)
|
||||
@@ -1089,7 +1105,7 @@ class PmsReservation(models.Model):
|
||||
def confirm(self):
|
||||
for record in self:
|
||||
vals = {}
|
||||
if record.checkin_partner_ids:
|
||||
if record.checkin_partner_ids.filtered(lambda c: c.state == "onboard"):
|
||||
vals.update({"state": "onboard"})
|
||||
else:
|
||||
vals.update({"state": "confirm"})
|
||||
|
||||
@@ -459,7 +459,7 @@ class PmsService(models.Model):
|
||||
)
|
||||
for line in self:
|
||||
state = line.folio_id.state or "draft"
|
||||
if state in ("draft"):
|
||||
if state == "draft":
|
||||
line.invoice_status = "no"
|
||||
elif not float_is_zero(line.qty_to_invoice, precision_digits=precision):
|
||||
line.invoice_status = "to invoice"
|
||||
|
||||
@@ -91,15 +91,9 @@ class TestPmsCheckinPartner(TestHotel):
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
|
||||
# ACT
|
||||
self.checkin1.action_on_board()
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
self.checkin1.state,
|
||||
"onboard",
|
||||
"the partner checkin was not successful",
|
||||
)
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||
self.reservation_1.state = "onboard"
|
||||
|
||||
def test_onboard_reservation(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user