mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Fix saved from checkin_parter in portal
This commit is contained in:
@@ -306,32 +306,72 @@ class PortalPrecheckin(CustomerPortal):
|
||||
@http.route(["/my/precheckin"], type="http", auth="user", website=True, csrf=False)
|
||||
def portal_precheckin_submit(self, **kw):
|
||||
checkin_partner = request.env["pms.checkin.partner"].browse(int(kw.get("id")))
|
||||
if not checkin_partner.partner_id:
|
||||
ResPartner = request.env["res.partner"]
|
||||
res_partner = ResPartner.create(kw)
|
||||
kw.update(
|
||||
{
|
||||
"partner_id": res_partner.id,
|
||||
}
|
||||
)
|
||||
else:
|
||||
res_partner = checkin_partner.partner_id
|
||||
res_partner.write(kw)
|
||||
checkin_partner.write(kw)
|
||||
|
||||
@http.route(
|
||||
["/my/precheckin/folio"], type="http", auth="user", website=False, csrf=True
|
||||
["/my/precheckin/folio_reservation"],
|
||||
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)
|
||||
counter = 1
|
||||
if kw.get("folio_id"):
|
||||
folio = request.env["pms.folio"].browse(int(kw.get("folio_id")))
|
||||
checkin_partners = len(folio.checkin_partner_ids)
|
||||
elif kw.get("reservation_id"):
|
||||
reservation = request.env["pms.reservation"].browse(
|
||||
int(kw.get("reservation_id"))
|
||||
)
|
||||
checkin_partners = len(reservation.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[
|
||||
"firstname": kw.get("firstname-" + str(counter)),
|
||||
"lastname": kw.get("lastname-" + str(counter)),
|
||||
"lastname2": kw.get("lastname2-" + str(counter)),
|
||||
"gender": kw.get("gender-" + str(counter)),
|
||||
"birthdate_date": kw.get("birthdate_date-" + str(counter))
|
||||
if kw.get("birthdate_date-" + str(counter))
|
||||
else False,
|
||||
"document_type": kw.get("document_type-" + str(counter)),
|
||||
"document_number": kw.get("document_number-" + str(counter)),
|
||||
"document_expedition_date": kw.get(
|
||||
"document_expedition_date-" + str(counter)
|
||||
],
|
||||
"mobile": kw["mobile-" + str(counter)],
|
||||
"email": kw["email-" + str(counter)],
|
||||
)
|
||||
if kw.get("document_expedition_date-" + str(counter))
|
||||
else False,
|
||||
"mobile": kw.get("mobile-" + str(counter)),
|
||||
"email": kw.get("email-" + str(counter)),
|
||||
}
|
||||
checkin_partner_id = int(kw.get("id-" + str(counter)))
|
||||
checkin_partner = request.env["pms.checkin.partner"].browse(
|
||||
checkin_partner_id
|
||||
)
|
||||
lastname = True if kw.get("lastname-" + str(counter)) else False
|
||||
firstname = True if kw.get("firstname-" + str(counter)) else False
|
||||
lastname2 = True if kw.get("lastname2-" + str(counter)) else False
|
||||
if not checkin_partner.partner_id and (lastname or firstname or lastname2):
|
||||
ResPartner = request.env["res.partner"]
|
||||
res_partner = ResPartner.create(values)
|
||||
values.update(
|
||||
{
|
||||
"partner_id": res_partner.id,
|
||||
}
|
||||
)
|
||||
elif checkin_partner.partner_id:
|
||||
res_partner = checkin_partner.partner_id
|
||||
res_partner.write(values)
|
||||
checkin_partner.write(values)
|
||||
counter = counter + 1
|
||||
|
||||
@@ -244,5 +244,12 @@
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]" />
|
||||
<field name="perm_read" eval="True" />
|
||||
</record>
|
||||
<record id="res_partner_rule_portal" model="ir.rule">
|
||||
<field name="name">Res Partner Rule</field>
|
||||
<field name="model_id" ref="model_res_partner" />
|
||||
<field name="domain_force">[]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]" />
|
||||
<field name="perm_read" eval="True" />
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -179,214 +179,248 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-set="count" t-value="1" />
|
||||
<t
|
||||
t-foreach="reservation.checkin_partner_ids"
|
||||
t-as="checkin_partner"
|
||||
<t t-set="count" t-value="0" />
|
||||
<form
|
||||
class="collapse"
|
||||
action="/my/precheckin/folio_reservation"
|
||||
method="get"
|
||||
>
|
||||
<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
|
||||
type="button"
|
||||
class="btn btn-info"
|
||||
<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 <t t-esc="count" />
|
||||
</a>
|
||||
<a
|
||||
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
|
||||
class="text-primary"
|
||||
>
|
||||
<span class="fa fa-chevron-down fa-sm" />
|
||||
</a>
|
||||
|
||||
<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"
|
||||
t-att-value="birthdate_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"
|
||||
t-att-value="document_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"
|
||||
t-att-value="document_expedition_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="checkin_partner.id"
|
||||
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="Are you sure you want to do this?"
|
||||
>
|
||||
Confirm
|
||||
<span class="fa fa-long-arrow-right" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</t>
|
||||
<!-- <div t-attf-class="form-group col-xl-6 d-none">-->
|
||||
<!-- <input-->
|
||||
<!-- type="text"-->
|
||||
<!-- name="checkins"-->
|
||||
<!-- t-attf-class="form-control"-->
|
||||
<!-- t-att-value="checkins"-->
|
||||
<!-- />-->
|
||||
<!-- </div>-->
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
<div t-attf-class="form-group col-xl-6 d-none">
|
||||
<input
|
||||
type="text"
|
||||
t-att-name="'reservation_id'"
|
||||
t-attf-class="form-control"
|
||||
t-att-value="reservation_id or reservation.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>
|
||||
@@ -404,9 +438,14 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-set="count" t-value="1" />
|
||||
<form class="collapse" action="/my/precheckin/folio" method="get">
|
||||
<t t-set="count" t-value="0" />
|
||||
<form
|
||||
class="collapse"
|
||||
action="/my/precheckin/folio_reservation"
|
||||
method="get"
|
||||
>
|
||||
<t t-foreach="folio.reservation_ids" t-as="reservation">
|
||||
<t t-set="count_reservation" t-value="0" />
|
||||
<tr class="bg-light">
|
||||
<td colspan="4"><em
|
||||
class="font-weight-normal text-muted"
|
||||
@@ -428,18 +467,23 @@
|
||||
<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" />
|
||||
<t
|
||||
t-set="count_reservation"
|
||||
t-value="count_reservation+1"
|
||||
/>
|
||||
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<a t-att-href="checkin_partner.get_portal_url()">
|
||||
Checkin
|
||||
Checkin <t t-esc="count_reservation" />
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-info"
|
||||
<a
|
||||
data-toggle="collapse"
|
||||
t-att-data-target="id3"
|
||||
>Drop down</button>
|
||||
class="text-primary"
|
||||
>
|
||||
<span class="fa fa-chevron-down fa-sm" />
|
||||
</a>
|
||||
<div class="row o_portal_details">
|
||||
<div class="col-lg-8">
|
||||
<div
|
||||
@@ -499,9 +543,9 @@
|
||||
> Birth Date</label>
|
||||
<input
|
||||
type="date"
|
||||
t_att_name="'birthdate_date-'+ str(count)"
|
||||
t-att-name="'birthdate_date-'+ str(count)"
|
||||
t-attf-class="form-control"
|
||||
t-att-value="birth_date or checkin_partner.birthdate_date"
|
||||
t-att-value="birthdate_date or checkin_partner.birthdate_date"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
@@ -569,7 +613,7 @@
|
||||
type="text"
|
||||
t-att-name="'document_number-'+ str(count)"
|
||||
t-attf-class="form-control"
|
||||
t-att-value="doc_number or checkin_partner.document_number"
|
||||
t-att-value="document_number or checkin_partner.document_number"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
@@ -583,7 +627,7 @@
|
||||
type="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"
|
||||
t-att-value="document_expedition_date or checkin_partner.document_expedition_date"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
@@ -656,5 +700,10 @@
|
||||
</tbody>
|
||||
</t>
|
||||
</t>
|
||||
<script>
|
||||
function myFunction(){
|
||||
window.prompt('Checkinssssss!');
|
||||
}
|
||||
</script>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user