From 278aecb96c9636786994b4203673e16274541554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Mon, 30 Nov 2020 19:48:27 +0100 Subject: [PATCH] [IMP] Checkin Flouw status --- pms/models/pms_checkin_partner.py | 4 +- pms/models/pms_reservation.py | 74 +++++++++++++++++++------ pms/views/pms_checkin_partner_views.xml | 6 -- pms/views/pms_reservation_views.xml | 39 +++++++------ 4 files changed, 79 insertions(+), 44 deletions(-) diff --git a/pms/models/pms_checkin_partner.py b/pms/models/pms_checkin_partner.py index 37092785b..c364c8e2e 100644 --- a/pms/models/pms_checkin_partner.py +++ b/pms/models/pms_checkin_partner.py @@ -110,7 +110,7 @@ class PmsCheckinPartner(models.Model): @api.constrains("departure", "arrival") def _check_departure(self): for record in self: - if record.departure and record.arrival < record.departure: + if record.departure and record.arrival > record.departure: raise ValidationError( _("Departure date (%s) is prior to arrival on %s") % (record.departure, record.arrival) @@ -158,7 +158,7 @@ class PmsCheckinPartner(models.Model): "arrival": fields.Datetime.now(), } record.update(vals) - if record.reservation_id.state == "confirm": + if record.reservation_id.left_for_checkin: record.reservation_id.state = "onboard" def action_done(self): diff --git a/pms/models/pms_reservation.py b/pms/models/pms_reservation.py index 40c261508..52454cd31 100644 --- a/pms/models/pms_reservation.py +++ b/pms/models/pms_reservation.py @@ -205,20 +205,24 @@ class PmsReservation(models.Model): compute="_compute_checkins_ratio", ) pending_checkin_data = fields.Integer( - "Pending Checkin Data", + "Checkin Data", compute="_compute_pending_checkin_data", store=True, ) - arrival_today = fields.Boolean( - compute="_compute_arrival_today", search="_search_arrival_today" + ratio_checkin_data = fields.Integer( + string="Pending Checkin Data", + compute="_compute_ratio_checkin_data", + ) + ready_for_checkin = fields.Boolean(compute="_compute_ready_for_checkin") + left_for_checkin = fields.Boolean( + compute="_compute_left_for_checkin", search="_search_left_for_checkin" + ) + checkin_today = fields.Boolean( + compute="_compute_checkin_today", search="_search_checkin_today" ) departure_today = fields.Boolean( compute="_compute_departure_today", search="_search_departure_today" ) - ratio_checkin_data = fields.Integer( - string="Pending Checkin Data Ratio", - compute="_compute_ratio_checkin_data", - ) segmentation_ids = fields.Many2many( "res.partner.category", string="Segmentation", @@ -676,14 +680,56 @@ class PmsReservation(models.Model): / reservation.adults ) - def _compute_arrival_today(self): + def _compute_left_for_checkin(self): + # Reservations still pending entry today for record in self: - record.arrival_today = ( + record.left_for_checkin = ( + True + if ( + record.state in ["draft", "confirm", "no_show"] + and record.checkin <= fields.Date.today() + ) + else False + ) + + def _search_left_for_checkin(self, operator, value): + if operator not in ("=",): + raise UserError( + _("Invalid domain operator %s for left of checkin", operator) + ) + + if value not in (True,): + raise UserError( + _("Invalid domain right operand %s for left of checkin", value) + ) + + today = fields.Date.context_today(self) + return [ + ("state", "in", ("draft", "confirm", "no_show")), + ("checkin", "<=", today), + ] + + def _compute_ready_for_checkin(self): + # Reservations with hosts data enought to checkin + for record in self: + record.ready_for_checkin = ( + record.left_for_checkin + and len( + record.checkin_partner_ids.filtered( + lambda c: c.state == "precheckin" + ) + ) + >= 1 + ) + + def _compute_checkin_today(self): + for record in self: + record.checkin_today = ( True if record.checkin == fields.Date.today() else False ) # REVIEW: Late checkin?? (next day) - def _search_arrival_today(self, operator, value): + def _search_checkin_today(self, operator, value): if operator not in ("=", "!="): raise UserError(_("Invalid domain operator %s", operator)) @@ -1171,14 +1217,6 @@ class PmsReservation(models.Model): record.folio_id.action_confirm() return True - def button_done(self): - """ - @param self: object pointer - """ - for record in self: - record.action_reservation_checkout() - return True - def action_cancel(self): for record in self: cancel_reason = ( diff --git a/pms/views/pms_checkin_partner_views.xml b/pms/views/pms_checkin_partner_views.xml index 99e3b1dec..6e985c9ae 100644 --- a/pms/views/pms_checkin_partner_views.xml +++ b/pms/views/pms_checkin_partner_views.xml @@ -230,12 +230,6 @@ -
- -
diff --git a/pms/views/pms_reservation_views.xml b/pms/views/pms_reservation_views.xml index c4e28441d..c1bc8593c 100644 --- a/pms/views/pms_reservation_views.xml +++ b/pms/views/pms_reservation_views.xml @@ -14,7 +14,7 @@
- +