[IMP]precheckin folio: change buttons in checkin rows for one button that submit all field values

This commit is contained in:
braisab
2021-05-02 16:24:14 +02:00
parent 71bd2ef095
commit 2c98308a35
2 changed files with 187 additions and 122 deletions

View File

@@ -307,10 +307,31 @@ class PortalPrecheckin(CustomerPortal):
def portal_precheckin_submit(self, **kw):
checkin_partner = request.env["pms.checkin.partner"].browse(int(kw.get("id")))
checkin_partner.write(kw)
reservation = request.env["pms.reservation"].browse(
checkin_partner.reservation_id
)
values = {
"reservation": reservation.id,
}
return request.render("pms.portal_my_reservation_precheckin", values)
@http.route(
["/my/precheckin/folio"], type="http", auth="user", website=False, csrf=True
)
def portal_precheckin_folio_submit(self, **kw):
counter = 2
folio = request.env["pms.folio"].browse(int(kw.get("folio_id")))
checkin_partners = len(folio.checkin_partner_ids)
for _checkin in range(checkin_partners):
values = {
"firstname": kw["firstname-" + str(counter)],
"lastname": kw["lastname-" + str(counter)],
"lastname2": kw["lastname2-" + str(counter)],
"gender": kw["gender-" + str(counter)],
"document_type": kw["document_type-" + str(counter)],
"document_number": kw["document_number-" + str(counter)],
"document_expedition_date": kw[
"document_expedition_date-" + str(counter)
],
"mobile": kw["mobile-" + str(counter)],
"email": kw["email-" + str(counter)],
}
checkin_partner_id = int(kw.get("id-" + str(counter)))
checkin_partner = request.env["pms.checkin.partner"].browse(
checkin_partner_id
)
checkin_partner.write(values)
counter = counter + 1

View File

@@ -6,7 +6,7 @@
<form action="/my/precheckin" method="post">
<div class="row o_portal_details">
<div t-attf-class="form-group col-xl-6 d-none">
<input
<input
type="number"
name="id"
t-attf-class="form-control"
@@ -73,6 +73,7 @@
class="form-control"
id="gender"
name="gender"
t-att-value="gender or checkin_partner.gender"
>
<option value="female">Female</option>
<option value="male">Male</option>
@@ -88,6 +89,7 @@
class="form-control"
id="doc_type_id"
name="document_type"
t-att-value="document_type or checkin_partner.document_type"
>
<option value="D">DNI</option>
<option value="C">Driving License</option>
@@ -186,7 +188,7 @@
<t t-set="id2" t-value="'#'" />
<t t-set="id3" t-value="str(id2)+str(id1)" />
<t t-set="count" t-value="count+1" />
<form class="collapse" action="/my/reservations/precheckin">
<form class="collapse" action="/my/precheckin">
<tr>
<td colspan="4">
<a t-att-href="checkin_partner.get_portal_url()">
@@ -258,6 +260,7 @@
class="form-control"
id="gender"
name="gender"
t-att-value="gender or checkin_partner.gender"
>
<option
value="female"
@@ -279,6 +282,7 @@
class="form-control"
id="doc_type_id"
name="document_type"
t-att-value="document_type or checkin_partner.document_type"
>
<option value="D">DNI</option>
<option
@@ -364,6 +368,7 @@
<button
type="submit"
class="btn btn-primary float-right mb32 "
confirm="Are you sure you want to do this?"
>
Confirm
<span class="fa fa-long-arrow-right" />
@@ -399,216 +404,255 @@
</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(suffix='/precheckin')"
t-att-title="reservation.name"
>
<t t-esc="reservation.name" />
</a>
</td>
</tr>
<t t-set="count" t-value="1" />
<t
t-foreach="reservation.checkin_partner_ids"
t-as="checkin_partner"
>
<t t-set="id1" t-value="'counter'+ str(count)" />
<t t-set="id2" t-value="'#'" />
<t t-set="id3" t-value="str(id2)+str(id1)" />
<t t-set="count" t-value="count+1" />
<form class="collapse" action="/my/precheckin">
<tr>
<td colspan="4">
<a t-att-href="checkin_partner.get_portal_url()">
Checkin
</a>
<button
<t t-set="count" t-value="1" />
<form class="collapse" action="/my/precheckin/folio" method="get">
<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(suffix='/precheckin')"
t-att-title="reservation.name"
>
<t t-esc="reservation.name" />
</a>
</td>
</tr>
<t
t-foreach="reservation.checkin_partner_ids"
t-as="checkin_partner"
>
<t t-set="id1" t-value="'counter'+ str(count)" />
<t t-set="id2" t-value="'#'" />
<t t-set="id3" t-value="id2+id1" />
<t t-set="idcheckin" t-value="'checkin' + str(count)" />
<t t-set="count" t-value="count+1" />
<tr>
<td colspan="4">
<a t-att-href="checkin_partner.get_portal_url()">
Checkin
</a>
<button
type="button"
class="btn btn-info"
data-toggle="collapse"
t-att-data-target="id3"
>Drop down</button>
<div class="row o_portal_details">
<div class="col-lg-8">
<div class="row collapse" t-att-id="id1">
<div t-attf-class="form-group col-xl-6">
<label
<div class="row o_portal_details">
<div class="col-lg-8">
<div
class="row collapse"
t-att-id="id1"
>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="firstname"
>Name</label>
<input
<input
type="text"
name="firstname"
t-att-name="'firstname-' + str(count)"
t-attf-class="form-control"
t-att-value="firstname or checkin_partner.firstname"
t-att-id="idcheckin"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="lastname"
>Lastname</label>
<input
<input
type="text"
name="lastname"
t-att-name="'lastname-' + str(count)"
t-attf-class="form-control"
t-att-value="lastname or checkin_partner.lastname"
t-att-id="idcheckin"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="lastname2"
> Second Lastname</label>
<input
<input
type="text"
name="lastname2"
t-att-name="'lastname2-' + str(count)"
t-attf-class="form-control"
t-att-value="lastname2 or checkin_partner.lastname2"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="birthdate_date"
> Birth Date</label>
<input
<input
type="date"
name="birthdate_date"
t_att_name="'birthdate_date-'+ str(count)"
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
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="gender"
>Gender</label>
<select
<select
class="form-control"
id="gender"
name="gender"
t-att-name="'gender-'+ str(count)"
t-att-value="gender or checkin_partner.gender"
>
<option
<option
value="female"
>Female</option>
<option
<option
value="male"
>Male</option>
<option
<option
value="other"
>Other</option>
</select>
</div>
<div t-attf-class="form-group col-xl-6">
<label
</select>
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="document_type"
>Doc. type</label>
<select
<select
class="form-control"
id="doc_type_id"
name="document_type"
t-att-name="'document_type-'+ str(count)"
t-att-value="document_type or checkin_partner.document_type"
>
<option value="D">DNI</option>
<option
<option
value="D"
>DNI</option>
<option
value="C"
>Driving License</option>
<option
<option
value="I"
>Identification Document</option>
<option
<option
value="N"
>Spanish residence permit</option>
<option
<option
value="X"
>European residence permit</option>
</select>
</div>
<div t-attf-class="form-group col-xl-6">
<label
</select>
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="document_number"
>Doc. number</label>
<input
<input
type="text"
name="document_number"
t-att-name="'document_number-'+ str(count)"
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
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="document_expedition_date"
>Doc. expedition date</label>
<input
<input
type="date"
name="document_expedition_date"
t-att-name="'document_expedition_date-'+ str(count)"
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
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="mobile"
>Mobile</label>
<input
<input
type="number"
name="mobile"
t-att-name="'mobile-'+ str(count)"
t-attf-class="form-control"
t-att-value="mobile or checkin_partner.mobile"
/>
</div>
<div t-attf-class="form-group col-xl-6">
<label
</div>
<div
t-attf-class="form-group col-xl-6"
>
<label
class="col-form-label"
for="email"
>Email</label>
<input
<input
type="email"
name="email"
t-att-name="'email-'+ str(count)"
t-attf-class="form-control"
t-att-value="email or checkin_partner.email"
/>
</div>
<div
</div>
<div
t-attf-class="form-group col-xl-6 d-none"
>
<input
<input
type="text"
name="id"
t-att-name="'id-'+ str(count)"
t-attf-class="form-control"
t-att-value="id or checkin_partner.id"
/>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="clearfix">
<button
type="submit"
class="btn btn-primary float-right mb32 "
>
Confirm
<span class="fa fa-long-arrow-right" />
</button>
</div>
</td>
</tr>
</form>
</td>
</tr>
</t>
</t>
</t>
<div t-attf-class="form-group col-xl-6 d-none">
<input
type="text"
t-att-name="'folio_id'"
t-attf-class="form-control"
t-att-value="folio_id or folio.id"
/>
</div>
<tr>
<td>
<div class="clearfix">
<button
type="submit"
class="btn btn-primary float-right mb32 "
>
Confirm
<span class="fa fa-long-arrow-right" />
</button>
</div>
</td>
</tr>
</form>
</tbody>
</t>
</t>