mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
@@ -337,7 +337,7 @@ class PortalPrecheckin(CustomerPortal):
|
||||
"checkin_pos": 0,
|
||||
}
|
||||
)
|
||||
if checkin_partner.state != "draft":
|
||||
if checkin_partner.state not in ["dummy", "draft"]:
|
||||
return request.render("pms.portal_not_checkin", values)
|
||||
return request.render("pms.portal_my_reservation_precheckin", values)
|
||||
|
||||
@@ -403,7 +403,7 @@ class PortalPrecheckin(CustomerPortal):
|
||||
self._precheckin_get_page_view_values(checkin_partner_id.id, access_token)
|
||||
)
|
||||
values.update({"no_breadcrumbs": True})
|
||||
if checkin_partner_id.state != "draft":
|
||||
if checkin_partner_id.state not in ["dummy", "draft"]:
|
||||
return request.render("pms.portal_not_checkin", values)
|
||||
return request.render("pms.portal_my_precheckin_detail", values)
|
||||
|
||||
|
||||
@@ -118,7 +118,8 @@ class PmsCheckinPartner(models.Model):
|
||||
readonly=True,
|
||||
store=True,
|
||||
selection=[
|
||||
("draft", "Unkown Guest"),
|
||||
("dummy", "Unkown Guest"),
|
||||
("draft", "Incomplete data"),
|
||||
("precheckin", "Pending arrival"),
|
||||
("onboard", "On Board"),
|
||||
("done", "Out"),
|
||||
@@ -406,15 +407,20 @@ class PmsCheckinPartner(models.Model):
|
||||
for record in self.filtered("reservation_id"):
|
||||
record.folio_id = record.reservation_id.folio_id
|
||||
|
||||
@api.depends(lambda self: self._checkin_mandatory_fields(depends=True))
|
||||
@api.depends(lambda self: self._checkin_manual_fields(depends=True))
|
||||
def _compute_state(self):
|
||||
for record in self:
|
||||
if not record.state:
|
||||
record.state = "draft"
|
||||
record.state = "dummy"
|
||||
if record.reservation_id.state == "cancel":
|
||||
record.state = "cancel"
|
||||
elif record.state in ("draft", "precheckin", "cancel"):
|
||||
if any(
|
||||
elif record.state in ("dummy", "draft", "precheckin", "cancel"):
|
||||
if all(
|
||||
not getattr(record, field)
|
||||
for field in record._checkin_manual_fields()
|
||||
):
|
||||
record.state = "dummy"
|
||||
elif any(
|
||||
not getattr(record, field)
|
||||
for field in record._checkin_mandatory_fields(
|
||||
country=record.nationality_id
|
||||
@@ -692,8 +698,8 @@ class PmsCheckinPartner(models.Model):
|
||||
# the reservation adults are computed
|
||||
if not reservation.checkin_partner_ids:
|
||||
reservation.flush()
|
||||
draft_checkins = reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state == "draft"
|
||||
dummy_checkins = reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state == "dummy"
|
||||
)
|
||||
if len(reservation.checkin_partner_ids) < reservation.adults:
|
||||
if vals.get("identifier", _("New")) == _("New") or "identifier" not in vals:
|
||||
@@ -705,9 +711,9 @@ class PmsCheckinPartner(models.Model):
|
||||
pms_property = self.env["pms.property"].browse(pms_property_id)
|
||||
vals["identifier"] = pms_property.checkin_sequence_id._next_do()
|
||||
return super(PmsCheckinPartner, self).create(vals)
|
||||
if len(draft_checkins) > 0:
|
||||
draft_checkins[0].write(vals)
|
||||
return draft_checkins[0]
|
||||
if len(dummy_checkins) > 0:
|
||||
dummy_checkins[0].write(vals)
|
||||
return dummy_checkins[0]
|
||||
raise ValidationError(
|
||||
_("Is not possible to create the proposed check-in in this reservation")
|
||||
)
|
||||
@@ -718,6 +724,34 @@ class PmsCheckinPartner(models.Model):
|
||||
reservations._compute_checkin_partner_ids()
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _checkin_manual_fields(self, country=False, depends=False):
|
||||
manual_fields = [
|
||||
"name",
|
||||
"partner_id",
|
||||
"email",
|
||||
"mobile",
|
||||
"phone",
|
||||
"gender",
|
||||
"firstname",
|
||||
"lastname",
|
||||
"lastname2",
|
||||
"birthdate_date",
|
||||
"document_number",
|
||||
"document_expedition_date",
|
||||
"nationality_id",
|
||||
"residence_street",
|
||||
"residence_street2",
|
||||
"residence_zip",
|
||||
"residence_city",
|
||||
"residence_country_id",
|
||||
"residence_state_id",
|
||||
]
|
||||
# api.depends need "reservation_id.state" in the lambda function
|
||||
if depends:
|
||||
manual_fields.append("reservation_id.state")
|
||||
return manual_fields
|
||||
|
||||
@api.model
|
||||
def _checkin_mandatory_fields(self, country=False, depends=False):
|
||||
mandatory_fields = [
|
||||
|
||||
@@ -1013,7 +1013,7 @@ class PmsReservation(models.Model):
|
||||
lambda c: c.state in ("precheckin", "onboard", "done")
|
||||
)
|
||||
unassigned_checkins = reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state == "draft"
|
||||
lambda c: c.state in ("dummy", "draft")
|
||||
)
|
||||
leftover_unassigneds_count = (
|
||||
len(assigned_checkins) + len(unassigned_checkins) - adults
|
||||
@@ -1047,7 +1047,7 @@ class PmsReservation(models.Model):
|
||||
for reservation in self:
|
||||
reservation.count_pending_arrival = len(
|
||||
reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state in ("draft", "precheckin")
|
||||
lambda c: c.state in ("dummy", "draft", "precheckin")
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1065,7 +1065,9 @@ 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 == "draft")
|
||||
reservation.checkin_partner_ids.filtered(
|
||||
lambda c: c.state in ("dummy", "draft")
|
||||
)
|
||||
)
|
||||
|
||||
@api.depends("pending_checkin_data")
|
||||
@@ -1088,7 +1090,7 @@ class PmsReservation(models.Model):
|
||||
if (
|
||||
record.reservation_type != "out"
|
||||
and record.overnight_room
|
||||
and record.state in ["draft", "confirm", "arrival_delayed"]
|
||||
and record.state in ("draft", "confirm", "arrival_delayed")
|
||||
and record.checkin <= fields.Date.today()
|
||||
)
|
||||
else False
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree
|
||||
editable="bottom"
|
||||
decoration-danger="state == 'draft'"
|
||||
decoration-danger="state == 'dummy'"
|
||||
decoration-info="state == 'done'"
|
||||
decoration-muted="state == 'cancel'"
|
||||
decoration-success="state == 'onboard'"
|
||||
@@ -183,7 +183,7 @@
|
||||
<tree
|
||||
editable="bottom"
|
||||
create="false"
|
||||
decoration-danger="state == 'draft'"
|
||||
decoration-danger="state == 'dummy'"
|
||||
decoration-info="state == 'done'"
|
||||
decoration-muted="state == 'cancel'"
|
||||
decoration-success="state == 'onboard'"
|
||||
@@ -312,7 +312,7 @@
|
||||
<!--TODO: Use npm avatar generation? https://github.com/Ashwinvalento/cartoon-avatar-->
|
||||
<img
|
||||
alt="Draft"
|
||||
t-if="record.state.raw_value === 'draft'"
|
||||
t-if="record.state.raw_value === 'dummy'"
|
||||
t-att-src=""pms/static/description/avatar.png""
|
||||
/>
|
||||
<img
|
||||
@@ -330,7 +330,7 @@
|
||||
<field
|
||||
name="state"
|
||||
widget="label_selection"
|
||||
options="{'classes': {'draft': 'default', 'precheckin': 'info', 'onboard': 'warning', 'onboard': 'success', 'done': 'secondary'}}"
|
||||
options="{'classes': {'dummy': 'default', 'precheckin': 'info', 'onboard': 'warning', 'onboard': 'success', 'done': 'secondary'}}"
|
||||
/>
|
||||
</div>
|
||||
<field
|
||||
|
||||
@@ -51,3 +51,9 @@ class PmsCheckinParnert(models.Model):
|
||||
if depends or (country and country.code == CODE_SPAIN):
|
||||
mandatory_fields.append("residence_state_id")
|
||||
return mandatory_fields
|
||||
|
||||
@api.model
|
||||
def _checkin_manual_fields(self, country=False, depends=False):
|
||||
manual_fields = super(PmsCheckinParnert, self)._checkin_manual_fields(depends)
|
||||
manual_fields.extend(["support_number"])
|
||||
return manual_fields
|
||||
|
||||
Reference in New Issue
Block a user