mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Checkin Flouw status
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -230,12 +230,6 @@
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="oe_kanban_bottom_right">
|
||||
<field
|
||||
name="partner_id"
|
||||
widget="many2one_avatar_user"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<header>
|
||||
<field name="splitted" invisible="True" />
|
||||
<field name="tax_ids" invisible="1" />
|
||||
<field name="arrival_today" invisible="1" />
|
||||
<field name="checkin_today" invisible="1" />
|
||||
<field name="checkin_partner_count" invisible="1" />
|
||||
<button
|
||||
name="confirm"
|
||||
@@ -31,7 +31,7 @@
|
||||
/>
|
||||
<button
|
||||
name="action_reservation_checkout"
|
||||
string="Done"
|
||||
string="Check Out"
|
||||
states="onboard"
|
||||
type="object"
|
||||
/>
|
||||
@@ -80,11 +80,24 @@
|
||||
</div>
|
||||
<sheet>
|
||||
<field name="shared_folio" invisible="1" />
|
||||
<field name="left_for_checkin" invisible="1" />
|
||||
<field name="ready_for_checkin" invisible="1" />
|
||||
<field name="departure_today" invisible="1" />
|
||||
<div
|
||||
class="oe_button_box"
|
||||
name="button_box"
|
||||
attrs="{'invisible': [('folio_id','=',False)]}"
|
||||
>
|
||||
<button
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-sign-out"
|
||||
name="action_reservation_checkout"
|
||||
>
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<span class="o_stat_text">Checkout</span>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
@@ -122,10 +135,7 @@
|
||||
class="oe_stat_button"
|
||||
name="action_onboard"
|
||||
attrs="{'invisible': [
|
||||
('state', '!=', ('onboard')),
|
||||
('arrival_today', '=', False),
|
||||
'|',
|
||||
('state', 'in', ('cancelled','done')),
|
||||
('ready_for_checkin', '!=', True),
|
||||
]}"
|
||||
>
|
||||
<field
|
||||
@@ -139,10 +149,7 @@
|
||||
class="oe_stat_button"
|
||||
name="action_checks"
|
||||
attrs="{'invisible': [
|
||||
('state', 'not in', ('onboard','confirm')),
|
||||
('arrival_today', '=', False),
|
||||
'|',
|
||||
('state', 'in', ('cancelled','done')),
|
||||
('left_for_checkin', '!=', True),
|
||||
]}"
|
||||
>
|
||||
<field
|
||||
@@ -571,12 +578,7 @@
|
||||
<field name="splitted" invisible="1" />
|
||||
<field name="pricelist_id" invisible="1" />
|
||||
<field name="rooms" />
|
||||
<field
|
||||
name="checkin"
|
||||
widget="daterange"
|
||||
class="oe_inline"
|
||||
options="{'related_end_date': 'checkout'}"
|
||||
/>
|
||||
<field name="checkin" />
|
||||
<field name="checkout" widget="date" />
|
||||
<field name="nights" />
|
||||
<button
|
||||
@@ -589,7 +591,8 @@
|
||||
<field name="allowed_room_ids" invisible="1" />
|
||||
<field name="partner_id" />
|
||||
<field name="room_type_id" invisible="1" />
|
||||
<field name="adults" string="Persons" />
|
||||
<field name="adults" />
|
||||
<field name="ratio_checkin_data" widget="progressbar" optional="show" />
|
||||
<field name="overbooking" invisible="1" />
|
||||
<field name="activity_ids" widget="list_activity" optional="show" />
|
||||
<field
|
||||
@@ -699,7 +702,7 @@
|
||||
<filter
|
||||
string="To enter"
|
||||
name="to_enter"
|
||||
domain="[('arrival_today', '=', True),('state', 'in', ('draft','confirm'))]"
|
||||
domain="[('left_for_checkin', '=', True)]"
|
||||
/>
|
||||
<filter
|
||||
string="Overbookings"
|
||||
|
||||
Reference in New Issue
Block a user