mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]: improvements in precheckin portal
This commit is contained in:
@@ -128,8 +128,8 @@ class PortalFolio(CustomerPortal):
|
||||
return request.redirect("/my")
|
||||
values.update(self._folio_get_page_view_values(folio_sudo, access_token, **kw))
|
||||
values.update({"no_breadcrumbs": True, "error": {}})
|
||||
country_ids = request.env['res.country'].search([])
|
||||
state_ids = request.env['res.country.state'].search([])
|
||||
country_ids = request.env["res.country"].search([])
|
||||
state_ids = request.env["res.country.state"].search([])
|
||||
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
|
||||
values.update(
|
||||
{
|
||||
@@ -175,9 +175,7 @@ class PortalReservation(CustomerPortal):
|
||||
auth="user",
|
||||
website=True,
|
||||
)
|
||||
def portal_my_reservations(
|
||||
self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw
|
||||
):
|
||||
def portal_my_reservations(self, page=1, date_begin=None, date_end=None):
|
||||
partner = request.env.user.partner_id
|
||||
values = self._prepare_portal_layout_values()
|
||||
Reservation = request.env["pms.reservation"]
|
||||
@@ -239,8 +237,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
|
||||
)
|
||||
@@ -252,9 +248,7 @@ class PortalReservation(CustomerPortal):
|
||||
auth="user",
|
||||
website=True,
|
||||
)
|
||||
def portal_my_reservation_precheckin(
|
||||
self, reservation_id, access_token=None, report_type=None, download=False, **kw
|
||||
):
|
||||
def portal_my_reservation_precheckin(self, reservation_id, access_token=None, **kw):
|
||||
try:
|
||||
reservation_sudo = self._document_check_access(
|
||||
"pms.reservation",
|
||||
@@ -298,26 +292,24 @@ class PortalPrecheckin(CustomerPortal):
|
||||
except (AccessError, MissingError):
|
||||
return request.redirect("/my")
|
||||
values = self._precheckin_get_page_view_values(checkin_sudo, access_token, **kw)
|
||||
country_ids = request.env['res.country'].search([])
|
||||
state_ids = request.env['res.country.state'].search([])
|
||||
doc_type_ids = request.env['res.partner.id_category'].sudo().search([])
|
||||
country_ids = request.env["res.country"].search([])
|
||||
state_ids = request.env["res.country.state"].search([])
|
||||
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
|
||||
values.update(
|
||||
{
|
||||
"doc_type_ids": doc_type_ids,
|
||||
"country_ids": country_ids,
|
||||
"state_ids": state_ids,
|
||||
"no_breadcrumbs": True,
|
||||
"error": {}
|
||||
"error": {},
|
||||
}
|
||||
)
|
||||
return request.render("pms.portal_my_precheckin_detail", values)
|
||||
|
||||
@http.route(["/my/precheckin"], type="http", auth="user", website=True, csrf=False)
|
||||
def portal_precheckin_submit(self, access_token=None, **kw):
|
||||
def portal_precheckin_submit(self, **kw):
|
||||
values = dict()
|
||||
checkin_partner = request.env["pms.checkin.partner"].browse(
|
||||
int(kw.get("id"))
|
||||
)
|
||||
checkin_partner = request.env["pms.checkin.partner"].browse(int(kw.get("id")))
|
||||
values.update(
|
||||
{
|
||||
"checkin_partner": checkin_partner,
|
||||
@@ -325,8 +317,8 @@ class PortalPrecheckin(CustomerPortal):
|
||||
"error_message": {},
|
||||
}
|
||||
)
|
||||
country_ids = request.env['res.country'].search([])
|
||||
state_ids = request.env['res.country.state'].search([])
|
||||
country_ids = request.env["res.country"].search([])
|
||||
state_ids = request.env["res.country.state"].search([])
|
||||
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
|
||||
if kw:
|
||||
error, error_message = self.form_validate(kw, None)
|
||||
@@ -341,35 +333,34 @@ class PortalPrecheckin(CustomerPortal):
|
||||
}
|
||||
)
|
||||
if error:
|
||||
|
||||
return request.render("pms.portal_my_precheckin_detail", values)
|
||||
else:
|
||||
try:
|
||||
values = kw
|
||||
if values.get("document_type"):
|
||||
doc_type = request.env["res.partner.id_category"].sudo().search([("name", "=", values.get("document_type"))])
|
||||
doc_type = (
|
||||
request.env["res.partner.id_category"]
|
||||
.sudo()
|
||||
.search([("name", "=", values.get("document_type"))])
|
||||
)
|
||||
values.update(
|
||||
{
|
||||
"document_type": doc_type,
|
||||
}
|
||||
)
|
||||
request.env["pms.checkin.partner"].sudo()._save_data_from_portal(values)
|
||||
doc_type_ids = request.env['res.partner.id_category'].sudo().search([])
|
||||
request.env["pms.checkin.partner"].sudo()._save_data_from_portal(
|
||||
values
|
||||
)
|
||||
doc_type_ids = (
|
||||
request.env["res.partner.id_category"].sudo().search([])
|
||||
)
|
||||
values.update(
|
||||
{
|
||||
"doc_type_ids": doc_type_ids,
|
||||
}
|
||||
)
|
||||
# if values.get("document_type"):
|
||||
# doc_type_id = values.get("document_type")
|
||||
# doc_type = request.env["res.partner.id_category"].sudo().search([("id", "=", doc_type_id)])
|
||||
# values.update(
|
||||
# {
|
||||
# "document_type": doc_type,
|
||||
# }
|
||||
# )
|
||||
country_ids = request.env['res.country'].search([])
|
||||
state_ids = request.env['res.country.state'].search([])
|
||||
country_ids = request.env["res.country"].search([])
|
||||
state_ids = request.env["res.country.state"].search([])
|
||||
values.update(
|
||||
{
|
||||
"country_ids": country_ids,
|
||||
@@ -409,40 +400,36 @@ class PortalPrecheckin(CustomerPortal):
|
||||
int(kw.get("reservation_id"))
|
||||
)
|
||||
checkin_partners = reservation.checkin_partner_ids
|
||||
country_ids = request.env['res.country'].search([])
|
||||
state_ids = request.env['res.country.state'].search([])
|
||||
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
|
||||
values = {
|
||||
"no_breadcrumbs": True,
|
||||
"country_ids": country_ids,
|
||||
"state_ids": state_ids,
|
||||
"doc_type_ids": doc_type_ids,
|
||||
}
|
||||
for checkin in checkin_partners:
|
||||
values.update(
|
||||
{
|
||||
"id": kw.get("id-" + str(counter)),
|
||||
"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)
|
||||
)
|
||||
if kw.get("document_expedition_date-" + str(counter))
|
||||
else False,
|
||||
"mobile": kw.get("mobile-" + str(counter)),
|
||||
"email": kw.get("email-" + str(counter)),
|
||||
}
|
||||
)
|
||||
values = {
|
||||
"id": kw.get("id-" + str(counter)),
|
||||
"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)
|
||||
)
|
||||
if kw.get("document_expedition_date-" + str(counter))
|
||||
else False,
|
||||
"mobile": kw.get("mobile-" + str(counter)),
|
||||
"email": kw.get("email-" + str(counter)),
|
||||
"nationality_id": kw.get("nationality_id-" + str(counter)),
|
||||
"state": kw.get("state-" + str(counter)),
|
||||
}
|
||||
|
||||
if values.get("document_type"):
|
||||
doc_type_code = values.get("document_type")
|
||||
doc_type = request.env["res.partner.id_category"].sudo().search([("code", "=", doc_type_code)])
|
||||
doc_type = (
|
||||
request.env["res.partner.id_category"]
|
||||
.sudo()
|
||||
.search([("name", "=", doc_type_code)])
|
||||
)
|
||||
values.update(
|
||||
{
|
||||
"document_type": doc_type,
|
||||
@@ -450,19 +437,30 @@ class PortalPrecheckin(CustomerPortal):
|
||||
)
|
||||
error, error_message = self.form_validate(kw, counter)
|
||||
errors.update(error)
|
||||
e_messages.update(error_message)
|
||||
if error_message:
|
||||
has_error = True
|
||||
else:
|
||||
checkin.sudo()._save_data_from_portal(values)
|
||||
counter = counter + 1
|
||||
values = {"no_breadcrumbs": True}
|
||||
|
||||
doc_type_ids = request.env["res.partner.id_category"].sudo().search([])
|
||||
country_ids = request.env["res.country"].search([])
|
||||
state_ids = request.env["res.country.state"].search([])
|
||||
values.update(
|
||||
{
|
||||
"doc_type_ids": doc_type_ids,
|
||||
"country_ids": country_ids,
|
||||
"state_ids": state_ids,
|
||||
}
|
||||
)
|
||||
if has_error:
|
||||
filtered_dict = {k: v for k, v in errors.items() if v}
|
||||
values.update({"error": filtered_dict})
|
||||
filtered_dict_error = {k: v for k, v in errors.items() if v}
|
||||
filtered_dict_error_messages = {k: v for k, v in e_messages.items() if v}
|
||||
values.update(
|
||||
{
|
||||
"error_message": e_messages,
|
||||
"error": filtered_dict_error,
|
||||
"error_message": filtered_dict_error_messages,
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -539,11 +537,13 @@ class PortalPrecheckin(CustomerPortal):
|
||||
)
|
||||
if data[document_expedition_date] and not data[document_number]:
|
||||
error[document_expedition_date] = "error"
|
||||
error_message[document_expedition_date] = "Document Number not entered and Document Type is not selected"
|
||||
error_message[
|
||||
document_expedition_date
|
||||
] = "Document Number not entered and Document Type is not selected"
|
||||
if data[document_number]:
|
||||
if not data[document_type]:
|
||||
error[document_type] = "error"
|
||||
error_message[document_type] ="Document Type is not selected"
|
||||
error_message[document_type] = "Document Type is not selected"
|
||||
if data[document_type] == "D":
|
||||
if len(data[document_number]) == 9 or len(data[document_number]) == 10:
|
||||
if not re.match(r"^\d{8}[ -]?[a-zA-Z]$", data[document_number]):
|
||||
@@ -576,8 +576,8 @@ class PortalPrecheckin(CustomerPortal):
|
||||
}
|
||||
dni_number = data[document_number][0:8]
|
||||
dni_letter = data[document_number][
|
||||
len(data[document_number]) - 1 : len(data[document_number])
|
||||
]
|
||||
len(data[document_number]) - 1 : len(data[document_number])
|
||||
]
|
||||
if letters.get(int(dni_number) % 23) != dni_letter.upper():
|
||||
error[document_number] = "error"
|
||||
error_message[document_number] = "DNI format is invalid"
|
||||
@@ -593,27 +593,33 @@ class PortalPrecheckin(CustomerPortal):
|
||||
r"^[X|Y]{1}[ -]?\d{7,8}[ -]?[a-zA-Z]$", data[document_number]
|
||||
):
|
||||
error[document_number] = "error"
|
||||
error_message[document_number] = "The Spanish Residence Permit format is wrong"
|
||||
error_message[
|
||||
document_number
|
||||
] = "The Spanish Residence Permit format is wrong"
|
||||
if data[document_type] == "X" and not re.match(
|
||||
r"^[X|Y]{1}[ -]?\d{7,8}[ -]?[a-zA-Z]$", data[document_number]
|
||||
):
|
||||
error[document_number] = "error"
|
||||
error_message[document_number] = "The European Residence Permit format is wrong"
|
||||
error_message[
|
||||
document_number
|
||||
] = "The European Residence Permit format is wrong"
|
||||
elif data[document_type]:
|
||||
error[document_number] = "error"
|
||||
error_message[document_number] = "Document Number not entered"
|
||||
return error, error_message
|
||||
|
||||
|
||||
@http.route(
|
||||
["/my/precheckin/send_invitation"],
|
||||
auth="user",
|
||||
type="json",
|
||||
website=True,
|
||||
csrf=False,
|
||||
)
|
||||
def portal_precheckin_folio_send_invitation(self, **kw):
|
||||
print(kw)
|
||||
# checkin_partner_id = kw.get("checkin_partner_id")
|
||||
# checkin_partner = request.env["pms.checkin.partner"].search([("id", "=", checkin_partner_id)])
|
||||
# print(checkin_partner)
|
||||
return request.redirect("/my")
|
||||
checkin_partner = request.env["pms.checkin.partner"].browse(
|
||||
int(kw["checkin_partner_id"])
|
||||
)
|
||||
url = kw.get("url_access_token")
|
||||
firstname = kw["firstname"]
|
||||
email = kw["email"]
|
||||
checkin_partner.send_portal_invitation_email(url, firstname, email)
|
||||
|
||||
Reference in New Issue
Block a user