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