[IMP] added precheckin option for reservation in portal

This commit is contained in:
braisab
2021-04-29 11:27:56 +02:00
parent e173ca4c98
commit c74cb60500
4 changed files with 295 additions and 196 deletions

View File

@@ -233,12 +233,14 @@ class PortalReservation(CustomerPortal):
return request.render("pms.portal_my_reservation_detail", values)
@http.route(
["/my/reservations/precheckin/<int:reservation_id>"],
["/my/reservations/<int:reservation_id>/precheckin"],
type="http",
auth="user",
website=True,
)
def portal_my_reservation_precheckin(self, reservation_id, access_token=None, **kw):
def portal_my_reservation_precheckin(
self, reservation_id, access_token=None, report_type=None, download=False, **kw
):
try:
reservation_sudo = self._document_check_access(
"pms.reservation",
@@ -247,8 +249,6 @@ class PortalReservation(CustomerPortal):
)
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
)
@@ -282,52 +282,6 @@ class PortalPrecheckin(CustomerPortal):
**kwargs
)
@http.route(
["/my/precheckins", "/my/precheckins/page/<int:page>"],
type="http",
auth="user",
website=True,
)
def portal_my_precheckin(
self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw
):
partner = request.env.user.partner_id
values = self._prepare_portal_layout_values()
Reservation = request.env["pms.reservation"]
values["reservations"] = Reservation.search(
[
("partner_id", "child_of", partner.id),
]
)
domain = [
("partner_id", "child_of", partner.id),
]
if date_begin and date_end:
domain += [
("create_date", ">", date_begin),
("create_date", "<=", date_end),
]
reservations = Reservation.search(domain)
checkin_count = len(reservations.checkin_partner_ids)
pager = portal_pager(
url="/my/precheckins",
url_args={"date_begin": date_begin, "date_end": date_end},
total=checkin_count,
page=page,
step=self._items_per_page,
)
request.session["my_precheckins_history"] = reservations.ids[:100]
values.update(
{
"date": date_begin,
"page_name": "precheckins",
"pager": pager,
"default_url": "/my/precheckins",
}
)
return request.render("pms.portal_my_precheckin", values)
@http.route(
["/my/precheckin/<int:checkin_partner_id>"],
type="http",
@@ -343,7 +297,5 @@ class PortalPrecheckin(CustomerPortal):
)
except (AccessError, MissingError):
return request.redirect("/my")
# for attachment in reservation_sudo.attachment_ids:
# attachment.generate_access_token()
values = self._precheckin_get_page_view_values(checkin_sudo, access_token, **kw)
return request.render("pms.portal_my_precheckin_detail", values)

View File

@@ -171,11 +171,6 @@
</xpath>
</template>
<!--
Sales Order content : intro, informations, order lines, remarks, descriptions ....
This template should contains all the printable element of the SO. This is the
template rendered in PDF with the report engine.
-->
<template id="folio_portal_content" name="Folio Portal Content">
<t t-set="address">
<div
@@ -504,7 +499,7 @@
class="font-weight-normal text-muted"
><span />Reservation: </em>
<a
t-att-href="reservation.get_portal_url()"
t-att-href="reservation.get_portal_url(suffix='/precheckin')"
t-att-title="reservation.name"
>
<t t-esc="reservation.name" />
@@ -520,20 +515,120 @@
<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>
<div class="row o_portal_details">
<div class="col-lg-8">
<div class="row">
<div t-attf-class="form-group col-xl-6">
<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.firstname"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Lastname</label>
<input
type="text"
name="lastname"
t-attf-class="form-control"
t-att-value="lastname or checkin_partner.lastname"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
> Second Lastname</label>
<input
type="text"
name="second_lastname"
t-attf-class="form-control"
t-att-value="lastname2 or checkin_partner.lastname2"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
> Birth Date</label>
<input
type="text"
name="birth_date"
t-attf-class="form-control"
t-att-value="birth_date or checkin_partner.birthdate_date"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label class="col-form-label" for="name">Gender</label>
<input
type="text"
name="gender"
t-attf-class="form-control"
t-att-value="gender or checkin_partner.gender"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Doc. type</label>
<input
type="text"
name="doc_type"
t-attf-class="form-control"
t-att-value="doc_type or checkin_partner.document_type"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Doc. number</label>
<input
type="text"
name="doc_number"
t-attf-class="form-control"
t-att-value="doc_number or checkin_partner.document_number"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Doc. expedition date</label>
<input
type="text"
name="doc_exp_date"
t-attf-class="form-control"
t-att-value="doc_exp_date or checkin_partner.document_expedition_date"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label class="col-form-label" for="name">Mobile</label>
<input
type="text"
name="mobile"
t-attf-class="form-control"
t-att-value="mobile or checkin_partner.mobile"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label class="col-form-label" for="name">Email</label>
<input
type="text"
name="email"
t-attf-class="form-control"
t-att-value="email or checkin_partner.email"
/>
</div>
</div>
</div>
</div>
</td>
</tr>
</t>

View File

@@ -1,127 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="portal_my_home_menu_precheckin"
name="Portal layout : precheckin menu entries"
inherit_id="portal.portal_breadcrumbs"
priority="30"
>
<xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside">
<li
t-if="page_name == 'precheckin'"
t-attf-class="breadcrumb-item #{'active ' if not reservations else ''}"
>
<a t-attf-href="/my/precheckin?{{ keep_query() }}">Precheckin</a>
</li>
<!-- <li t-if="reservation" class="breadcrumb-item active">-->
<!-- <a t-attf-href="/my/precheckin?{{ keep_query() }}">Precheckin/</a>-->
<!-- <t t-esc="reservation.name" />-->
<!-- </li>-->
</xpath>
</template>
<template
id="portal_my_precheckins"
name="Precheckins"
inherit_id="portal.portal_my_home"
customize_show="True"
priority="40"
>
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
<t t-call="portal.portal_docs_entry">
<t t-set="title">Precheckin</t>
<t t-set="url" t-value="'/my/precheckins'" />
<t t-set="placeholder_count" t-value="'checkin_count'" />
</t>
</xpath>
</template>
<template id="portal_my_precheckin" name="My PreCheckins">
<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 reservations">
<p>There are currently no reservations for your account.</p>
</t>
<t t-if="reservations" t-call="portal.portal_table">
<thead>
<tr class="active">
<th>PreCheckin #</th>
</tr>
</thead>
<tbody>
<t t-foreach="reservations" t-as="reservation">
<t t-set="folio" t-value="reservation.folio_id" />
<!-- Sacar folio-->
<t t-if="reservation == folio.reservation_ids[0]">
<tr class="bg-light">
<td colspan="4"><em
class="font-weight-normal text-muted"
><span />Folio: </em>
<a>
<t t-esc="folio.name" />
</a>
</td>
</tr>
</t>
<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>
<template id="portal_my_precheckin_detail" name="My Precheckin">
<t t-call="portal.portal_layout">
<t t-set="additional_title">Contact Details</t>
<form action="/my/precheckin" method="post">
<!-- <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>-->
<div class="row o_portal_details">
<div class="col-lg-8">
<div class="row">
<!-- <t t-set="partner_can_edit_vat" t-value="partner.can_edit_vat()"/>-->
<!-- <div class="col-lg-12">-->
<!-- <div t-if="error_message" class="alert alert-danger" role="alert">-->
<!-- <t t-foreach="error_message" t-as="err"><t t-esc="err"/><br /></t>-->
<!-- </div>-->
<!-- </div>-->
<div t-attf-class="form-group col-xl-6">
<label class="col-form-label" for="name">Name</label>
<input
@@ -143,8 +28,6 @@
t-att-value="lastname or checkin_partner.lastname"
/>
</div>
<!-- <div class="clearfix" />-->
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
@@ -214,10 +97,6 @@
t-att-value="doc_exp_date or checkin_partner.document_expedition_date"
/>
</div>
<!-- <div t-attf-class="form-group col-xl-6">-->
<!-- <label class="col-form-label" for="name">Phone</label>-->
<!-- <input type="text" name="phone" t-attf-class="form-control" t-att-value="phone or checkin_partner.phone" />-->
<!-- </div>-->
<div t-attf-class="form-group col-xl-6">
<label class="col-form-label" for="name">Mobile</label>
<input
@@ -239,6 +118,12 @@
</div>
</div>
</div>
<div class="clearfix">
<button type="submit" class="btn btn-primary float-right mb32 ">
Confirm
<span class="fa fa-long-arrow-right" />
</button>
</div>
</form>
</t>
</template>

View File

@@ -280,8 +280,175 @@
</t>
</template>
<template id="portal_my_reservation_precheckin" name="Precheckin Reservation">
<div class="row mt16">
<p>Hola</p>
</div>
<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 reservation.checkin_partner_ids">
<p
>There are currently no precheckins in this reserva for your account.</p>
</t>
<t t-if="reservation.checkin_partner_ids" t-call="portal.portal_table">
<thead>
<tr class="active">
<th>PreCheckin in Reservation <span
t-field="reservation.name"
/></th>
</tr>
</thead>
<tbody>
<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 class="row o_portal_details">
<div class="col-lg-8">
<div class="row">
<div t-attf-class="form-group col-xl-6">
<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.firstname"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Lastname</label>
<input
type="text"
name="lastname"
t-attf-class="form-control"
t-att-value="lastname or checkin_partner.lastname"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
> Second Lastname</label>
<input
type="text"
name="second_lastname"
t-attf-class="form-control"
t-att-value="lastname2 or checkin_partner.lastname2"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
> Birth Date</label>
<input
type="text"
name="birth_date"
t-attf-class="form-control"
t-att-value="birth_date or checkin_partner.birthdate_date"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Gender</label>
<input
type="text"
name="gender"
t-attf-class="form-control"
t-att-value="gender or checkin_partner.gender"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Doc. type</label>
<input
type="text"
name="doc_type"
t-attf-class="form-control"
t-att-value="doc_type or checkin_partner.document_type"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Doc. number</label>
<input
type="text"
name="doc_number"
t-attf-class="form-control"
t-att-value="doc_number or checkin_partner.document_number"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Doc. expedition date</label>
<input
type="text"
name="doc_exp_date"
t-attf-class="form-control"
t-att-value="doc_exp_date or checkin_partner.document_expedition_date"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Mobile</label>
<input
type="text"
name="mobile"
t-attf-class="form-control"
t-att-value="mobile or checkin_partner.mobile"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
class="col-form-label"
for="name"
>Email</label>
<input
type="text"
name="email"
t-attf-class="form-control"
t-att-value="email or checkin_partner.email"
/>
</div>
</div>
</div>
</div>
</td>
</tr>
</t>
<tr>
<td>
<button
type="submit"
class="btn btn-primary float-right mb32 "
>
Confirm<span class="fa fa-long-arrow-right" />
</button>
</td>
</tr>
</tbody>
</t>
</t>
</template>
</odoo>