[IMP] pms: error handling in precheckin portal

This commit is contained in:
Sara Lago
2022-11-18 19:53:21 +01:00
committed by Darío Lodeiros
parent 52e5e545bf
commit 91ca6d645a
3 changed files with 41 additions and 35 deletions

View File

@@ -378,12 +378,14 @@ class PortalPrecheckin(CustomerPortal):
if error: if error:
checkin_pos = checkin_pos - 1 checkin_pos = checkin_pos - 1
values.update({"checkin_pos": checkin_pos}) values.update({"checkin_pos": checkin_pos})
if checkin_pos == len(folio_id.checkin_partner_ids) or checkin_pos == -2: if checkin_pos == len(folio_id.checkin_partner_ids):
values = { values = {
"folio": folio_id, "folio": folio_id,
"no_breadcrumbs": True, "no_breadcrumbs": True,
} }
return request.render("pms.portal_my_precheckin_end", values) return request.render("pms.portal_my_precheckin_end", values)
if checkin_pos == -2:
return request.render("pms.portal_my_precheckin_end", values)
values.update( values.update(
{ {
"folio": folio_id, "folio": folio_id,

View File

@@ -15,7 +15,7 @@
<center> <center>
<h5 <h5
class="font-weight-bold mr-5 mt-2" class="font-weight-bold mr-5 mt-2"
t-esc="'Room: '+checkin_partner_id.reservation_id.sudo().room_type_id.name" t-esc="'Room: '+checkin_partner_id.reservation_id.sudo().room_type_id.name if checkin_partner_id.reservation_id else ''"
/> />
</center> </center>
<input <input
@@ -43,23 +43,26 @@
<t t-if="checkin_pos >= 0"> <t t-if="checkin_pos >= 0">
<div class="col-4 mt-2"> <div class="col-4 mt-2">
<h5 class="float-right font-weight-bold"> <h5 class="float-right font-weight-bold">
Check-in Covering <span
<span t-esc="int(checkin_pos) + 1" /> t-esc="int(checkin_pos) + 1"
/> partner <br />
<span
t-esc="len(folio.checkin_partner_ids.filtered(lambda c: c.state in ['dummy','draft']))-int(checkin_pos)"
/>
partner data to remain to be covered
</h5> </h5>
</div> </div>
</t> </t>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-11 col-md-8 row pt-3"> <div class="col-11 col-md-8 row pt-3">
<div t-attf-class="form-group col-12 col-md-6"> <div t-attf-class="form-group col-12 col-md-6">
<label <label class="col-form-label" for="firstname">Name<small
class="col-form-label" >*</small></label>
for="firstname"
>Name</label>
<input <input
type="text" type="text"
name="firstname" name="firstname"
t-attf-class="form-control #{error.get('firstname') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('firstname') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.firstname" t-att-value="firstname if error and firstname else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -77,7 +80,7 @@
type="text" type="text"
name="lastname" name="lastname"
t-attf-class="form-control #{error.get('firstname') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('firstname') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.lastname" t-att-value="lastname if lastname and error else ''"
/> />
</div> </div>
<div t-attf-class="form-group col-12 col-md-6 pb-md-5"> <div t-attf-class="form-group col-12 col-md-6 pb-md-5">
@@ -88,8 +91,8 @@
<input <input
type="text" type="text"
name="lastname2" name="lastname2"
t-attf-class="form-control #{error.get('firstname') and 'is-invalid' or ''}" t-attf-class="form-control"
t-att-value="checkin_partner_id.lastname2" t-att-value="lastname2 if error and lastname2 else ''"
/> />
</div> </div>
<div t-attf-class="col-12 col-md-6 pb-5"> <div t-attf-class="col-12 col-md-6 pb-5">
@@ -98,30 +101,30 @@
for="gender" for="gender"
>Gender</label> >Gender</label>
<div class="d-none"><p id="genderId"><t <div class="d-none"><p id="genderId"><t
t-esc="checkin_partner_id.gender" t-esc="gender"
/></p></div> /></p></div>
<select <select
class="form-control" class="form-control"
name="gender" name="gender"
t-att-value="checkin_partner_id.gender" t-att-value="gender if gender and error else ''"
t-attf-class="form-control #{error.get('gender') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('gender') and 'is-invalid' or ''}"
> >
<option value="">Select an option</option> <option value="">Select an option</option>
<option <option
value="female" value="female"
t-att-selected="'female' == checkin_partner_id.gender" t-att-selected="'female' == gender"
> >
Female Female
</option> </option>
<option <option
value="male" value="male"
t-att-selected="'male' == checkin_partner_id.gender" t-att-selected="'male' == gender"
> >
Male Male
</option> </option>
<option <option
value="other" value="other"
t-att-selected="'other' == checkin_partner_id.gender" t-att-selected="'other' == gender"
> >
Other Other
</option> </option>
@@ -143,7 +146,7 @@
for="document_type" for="document_type"
>Doc. Type</label> >Doc. Type</label>
<div class="d-none"><p id="docTypeId"><t <div class="d-none"><p id="docTypeId"><t
t-esc="checkin_partner_id.document_type" t-esc="document_type"
/></p></div> /></p></div>
<select <select
class="form-control #{error.get('document_type') and 'is-invalid' or ''}" class="form-control #{error.get('document_type') and 'is-invalid' or ''}"
@@ -154,7 +157,7 @@
<t t-foreach="doc_type_ids" t-as='doc_type'> <t t-foreach="doc_type_ids" t-as='doc_type'>
<option <option
t-att-value="doc_type.name" t-att-value="doc_type.name"
t-att-selected="doc_type.id == checkin_partner_id.document_type.id" t-att-selected="doc_type.name == document_type"
> >
<t t-esc='doc_type.name' /> <t t-esc='doc_type.name' />
</option> </option>
@@ -179,7 +182,7 @@
type="text" type="text"
name="document_number" name="document_number"
t-attf-class="form-control #{error.get('document_number') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('document_number') and 'is-invalid' or ''}"
t-att-value="doc_number or checkin_partner_id.document_number" t-att-value="document_number if document_number and error else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -204,7 +207,7 @@
type="date" type="date"
name="document_expedition_date" name="document_expedition_date"
t-attf-class="form-control #{error.get('document_expedition_date') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('document_expedition_date') and 'is-invalid' or ''}"
t-att-value="doc_exp_date or checkin_partner_id.document_expedition_date" t-att-value="document_expedition_date"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -222,7 +225,7 @@
type="date" type="date"
name="birthdate_date" name="birthdate_date"
t-attf-class="form-control #{error.get('birthdate_date') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('birthdate_date') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.birthdate_date" t-att-value="birthdate_date if birthdate_date and error else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -240,12 +243,13 @@
t-attf-class="form-control #{error.get('nationality_id') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('nationality_id') and 'is-invalid' or ''}"
id="country" id="country"
name='nationality_id' name='nationality_id'
value="nationality_id if nationality_id and error else ''"
> >
<option value="">Select an option</option> <option value="">Select an option</option>
<t t-foreach="country_ids" t-as='country_id'> <t t-foreach="country_ids" t-as='country_id'>
<option <option
t-att-value="country_id.id" t-att-value="country_id.id"
t-att-selected="country_id.id == checkin_partner_id.nationality_id.id" t-att-selected="str(country_id.id) == nationality_id"
> >
<t t-esc='country_id.name' /> <t t-esc='country_id.name' />
</option> </option>
@@ -268,7 +272,7 @@
type="phone" type="phone"
name="mobile" name="mobile"
t-attf-class="form-control #{error.get('mobile') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('mobile') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.mobile" t-att-value="mobile if mobile and error else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -287,7 +291,7 @@
type="phone" type="phone"
name="phone" name="phone"
t-attf-class="form-control #{error.get('phone') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('phone') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.phone" t-att-value="phone if phone and error else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -306,7 +310,7 @@
type="email" type="email"
name="email" name="email"
t-attf-class="form-control #{error.get('email') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('email') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.email" t-att-value="email if email and error else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span
@@ -325,7 +329,7 @@
placeholder="Street" placeholder="Street"
name="residence_street" name="residence_street"
t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.residence_street" t-att-value="residence_street if residence_street else ''"
/> />
</div> </div>
<div t-attf-class="form-group col-md-12"> <div t-attf-class="form-group col-md-12">
@@ -333,8 +337,8 @@
type="text" type="text"
placeholder="Second Street (Optional)" placeholder="Second Street (Optional)"
name="residence_street2" name="residence_street2"
t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}" t-attf-class="form-control"
t-att-value="checkin_partner_id.residence_street2" t-att-value="residence_street2 if residence_street2 and error else ''"
/> />
</div> </div>
<div t-attf-class="form-group col-md-4"> <div t-attf-class="form-group col-md-4">
@@ -343,7 +347,7 @@
placeholder="City" placeholder="City"
name="residence_city" name="residence_city"
t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.residence_city" t-att-value="residence_city if residence_city and error else ''"
/> />
</div> </div>
<div t-attf-class="form-group col-md-4"> <div t-attf-class="form-group col-md-4">
@@ -352,7 +356,7 @@
placeholder="Zip" placeholder="Zip"
name="residence_zip" name="residence_zip"
t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('address') and 'is-invalid' or ''}"
t-att-value="checkin_partner_id.residence_zip" t-att-value="residence_zip if residence_zip and error else ''"
/> />
</div> </div>
<div t-attf-class="form-group col-md-4"> <div t-attf-class="form-group col-md-4">
@@ -370,7 +374,7 @@
<t t-foreach="country_ids" t-as='country_id'> <t t-foreach="country_ids" t-as='country_id'>
<option <option
t-att-value="country_id.id" t-att-value="country_id.id"
t-att-selected="country_id.id == checkin_partner_id.residence_country_id.id if checkin_partner_id.residence_country_id.id else placeholder" t-att-selected="str(country_id.id) == residence_country_id if residence_country_id and error else placeholder"
> >
<t t-esc='country_id.name' /> <t t-esc='country_id.name' />
</option> </option>
@@ -393,7 +397,7 @@
<option <option
t-att-value="state.id" t-att-value="state.id"
t-att-country_id="state.country_id.id" t-att-country_id="state.country_id.id"
t-att-selected="state.id == checkin_partner_id.residence_state_id.id if checkin_partner_id.residence_state_id.id else placeholder" t-att-selected="str(state.id) == residence_state_id if residence_state_id and error else placeholder"
> >
<t t-esc="state.name" /> <t t-esc="state.name" />
</option> </option>

View File

@@ -18,7 +18,7 @@
<t t-foreach="doc_type_ids" t-as='doc_type'> <t t-foreach="doc_type_ids" t-as='doc_type'>
<option <option
t-att-value="doc_type.name" t-att-value="doc_type.name"
t-att-selected="doc_type.id == checkin_partner_id.document_type.id" t-att-selected="doc_type.name == document_type"
> >
<t t-esc='doc_type.name' /> <t t-esc='doc_type.name' />
</option> </option>
@@ -39,7 +39,7 @@
type="text" type="text"
name="document_number" name="document_number"
t-attf-class="form-control #{error.get('document_number') and 'is-invalid' or ''}" t-attf-class="form-control #{error.get('document_number') and 'is-invalid' or ''}"
t-att-value="doc_number or checkin_partner_id.document_number" t-att-value="document_number if document_number and error else ''"
/> />
<t t-if="error_message"> <t t-if="error_message">
<span <span