[IMP] Add folio precheckin views

This commit is contained in:
Sara Lago
2021-04-28 13:26:28 +02:00
committed by braisab
parent 9175167a9c
commit 78dd8e324d
6 changed files with 149 additions and 2 deletions

View File

@@ -109,6 +109,30 @@ class PortalFolio(CustomerPortal):
values = self._folio_get_page_view_values(folio_sudo, access_token, **kw)
return request.render("pms.folio_portal_template", values)
@http.route(
["/my/folios/precheckin/<int:folio_id>"], type="http", auth="user", website=True
)
def portal_my_folio_precheckin(
self, folio_id, access_token=None, report_type=None, download=False, **kw
):
try:
folio_sudo = self._document_check_access(
"pms.folio",
folio_id,
access_token=access_token,
)
except (AccessError, MissingError):
return request.redirect("/my")
if report_type in ("html", "pdf", "text"):
return self._show_report(
model=folio_sudo,
report_type=report_type,
report_ref="pms.action_report_folio",
download=download,
)
values = self._folio_get_page_view_values(folio_sudo, access_token, **kw)
return request.render("pms.portal_my_folio_precheckin", values)
class PortalReservation(CustomerPortal):
def _prepare_home_portal_values(self, counters):
@@ -215,6 +239,28 @@ class PortalReservation(CustomerPortal):
)
return request.render("pms.portal_my_reservation_detail", values)
@http.route(
["/my/reservations/precheckin/<int:reservation_id>"],
type="http",
auth="user",
website=True,
)
def portal_my_reservation_precheckin(self, reservation_id, access_token=None, **kw):
try:
reservation_sudo = self._document_check_access(
"pms.reservation",
reservation_id,
access_token=access_token,
)
except (AccessError, MissingError):
return request.redirect("/my")
# for attachment in reservation_sudo.attachment_ids:
# attachment.generate_access_token()
values = self._reservation_get_page_view_values(
reservation_sudo, access_token, **kw
)
return request.render("pms.portal_my_reservation_precheckin", values)
class PortalPrecheckin(CustomerPortal):
def _prepare_home_portal_values(self, counters):

View File

@@ -770,10 +770,40 @@ class PmsFolio(models.Model):
# else:
# raise UserError(_("Some reservations have different currency"))
is_checkin = fields.Boolean(default=False)
def _compute_access_url(self):
super(PmsFolio, self)._compute_access_url()
print(self.is_checkin)
for folio in self:
folio.access_url = "/my/folios/%s" % (folio.id)
if self.is_checkin:
folio.access_url = "/my/folios/precheckin/%s" % (folio.id)
self.is_checkin = False
def get_portal_url(
self,
suffix=None,
report_type=None,
download=None,
query_string=None,
anchor=None,
bol=None,
):
self.ensure_one()
if bol:
self.is_checkin = True
url = self.access_url + '%s?access_token=%s%s%s%s%s' % (
suffix if suffix else '',
self._portal_ensure_token(),
'&report_type=%s' % report_type if report_type else '',
'&download=true' if download else '',
query_string if query_string else '',
'#%s' % anchor if anchor else ''
)
return url
@api.depends("state", "sale_line_ids.invoice_status")
def _compute_get_invoice_status(self):

View File

@@ -1134,6 +1134,10 @@ class PmsReservation(models.Model):
record.checkout = False
# date checking
record.check_in_out_dates()
def _compute_precheckin_url(self):
super(PmsReservation, self)._compute_access_url()
for reservation in self:
reservation.access_url = "/my/reservations/precheckin/%s" % (reservation.id)
@api.depends("pms_property_id", "folio_id")
def _compute_arrival_hour(self):

View File

@@ -63,6 +63,10 @@
>
<t t-esc="folio.name" />
</a>
<a
t-att-href="folio.get_portal_url(bol=True)"
t-att-title="Precheckin"
>Precheckin</a>
</td>
<td><span t-field="folio.date_order" /></td>
<td class="text-right"><span
@@ -476,4 +480,64 @@
</p>
</div>
</template>
<template id="portal_my_folio_precheckin" name="Precheckin Folio">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True" />
<t t-call="portal.portal_searchbar">
<t t-set="title">Precheckins</t>
</t>
<t t-if="not folio.reservation_ids">
<p>There are currently no reservations in this folio for your account.</p>
</t>
<t t-if="folio.reservation_ids" t-call="portal.portal_table">
<thead>
<tr class="active">
<th>PreCheckin in Folio <span t-field="folio.name" /></th>
</tr>
</thead>
<tbody>
<t t-foreach="folio.reservation_ids" t-as="reservation">
<tr class="bg-light">
<td colspan="4"><em class="font-weight-normal text-muted"><span
/>Reservation: </em>
<a
t-att-href="reservation.get_portal_url()"
t-att-title="reservation.name"
>
<t t-esc="reservation.name" />
</a>
</td>
</tr>
<t
t-foreach="reservation.checkin_partner_ids"
t-as="checkin_partner"
>
<tr>
<td colspan="4">
<a t-att-href="checkin_partner.get_portal_url()">
Checkin
</a>
<div t-attf-class="form-group">
<div class="col-2">
<label
class="col-form-label"
for="name"
>Name: </label>
<input
type="text"
name="name"
t-attf-class="form-control"
t-att-value="name or checkin_partner.name"
/>
</div>
</div>
</td>
</tr>
</t>
</t>
</tbody>
</t>
</t>
</template>
</odoo>

View File

@@ -35,8 +35,6 @@
</xpath>
</template>
<template id="portal_my_precheckin" name="My PreCheckins">
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>-->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">-->
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True" />

View File

@@ -279,4 +279,9 @@
</div>
</t>
</template>
<template id="portal_my_reservation_precheckin" name="Precheckin Reservation">
<div class="row mt16">
<p>Hola</p>
</div>
</template>
</odoo>