mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] pms_l10n_es: fix traveller report bad identation & avoid length errors with phone/email & firstname
This commit is contained in:
@@ -44,6 +44,7 @@ class PmsSesCommunication(models.Model):
|
|||||||
default="to_send",
|
default="to_send",
|
||||||
required=True,
|
required=True,
|
||||||
selection=[
|
selection=[
|
||||||
|
("incomplete", "Incomplete checkin data"),
|
||||||
("to_send", "Pending Notification"),
|
("to_send", "Pending Notification"),
|
||||||
("to_process", "Pending Processing"),
|
("to_process", "Pending Processing"),
|
||||||
("error_sending", "Error Sending"),
|
("error_sending", "Error Sending"),
|
||||||
@@ -51,6 +52,7 @@ class PmsSesCommunication(models.Model):
|
|||||||
("processed", "Processed"),
|
("processed", "Processed"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
sending_result = fields.Text(
|
sending_result = fields.Text(
|
||||||
string="Sending Result",
|
string="Sending Result",
|
||||||
help="Notification sending result",
|
help="Notification sending result",
|
||||||
|
|||||||
@@ -90,25 +90,25 @@ def _ses_xml_map_document_type(code):
|
|||||||
|
|
||||||
def _ses_xml_person_names_elements(persona, reservation, checkin_partner):
|
def _ses_xml_person_names_elements(persona, reservation, checkin_partner):
|
||||||
if reservation:
|
if reservation:
|
||||||
name = False
|
ses_firstname = False
|
||||||
if reservation.partner_id.firstname:
|
if reservation.partner_id.firstname:
|
||||||
name = reservation.partner_id.firstname
|
ses_firstname = reservation.partner_id.firstname
|
||||||
elif reservation.partner_name:
|
elif reservation.partner_name:
|
||||||
name = reservation.partner_name.split(" ")[0]
|
ses_firstname = reservation.partner_name.split(" ")[0]
|
||||||
_ses_xml_text_element_and_validate(
|
_ses_xml_text_element_and_validate(
|
||||||
persona,
|
persona,
|
||||||
"nombre",
|
"nombre",
|
||||||
name,
|
ses_firstname,
|
||||||
_("The reservation does not have a name."),
|
_("The reservation does not have a name."),
|
||||||
)
|
)
|
||||||
|
|
||||||
if reservation.partner_id.lastname:
|
if reservation.partner_id.lastname:
|
||||||
firstname = reservation.partner_id.lastname
|
ses_lastname = reservation.partner_id.lastname
|
||||||
elif reservation.partner_name and len(reservation.partner_name.split(" ")) > 1:
|
elif reservation.partner_name and len(reservation.partner_name.split(" ")) > 1:
|
||||||
firstname = reservation.partner_name.split(" ")[1]
|
ses_lastname = reservation.partner_name.replace(" ", " ").split(" ")[1]
|
||||||
else:
|
else:
|
||||||
firstname = "No aplica"
|
ses_lastname = "No aplica"
|
||||||
ET.SubElement(persona, "apellido1").text = firstname
|
ET.SubElement(persona, "apellido1").text = ses_lastname
|
||||||
|
|
||||||
elif checkin_partner:
|
elif checkin_partner:
|
||||||
_ses_xml_text_element_and_validate(
|
_ses_xml_text_element_and_validate(
|
||||||
@@ -242,7 +242,12 @@ def _ses_xml_person_contact_elements(persona, reservation, checkin_partner=False
|
|||||||
|
|
||||||
for contact in contact_methods:
|
for contact in contact_methods:
|
||||||
if contact:
|
if contact:
|
||||||
tag = "telefono" if "@" not in contact else "correo"
|
if "@" in contact:
|
||||||
|
tag = "correo"
|
||||||
|
contact = contact[0:50]
|
||||||
|
else:
|
||||||
|
tag = "telefono"
|
||||||
|
contact = contact[0:20]
|
||||||
ET.SubElement(persona, tag).text = contact
|
ET.SubElement(persona, tag).text = contact
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@@ -323,7 +328,8 @@ def _handle_request_exception(communication, e):
|
|||||||
if communication.state == "to_send":
|
if communication.state == "to_send":
|
||||||
communication.sending_result = f"Request error: {e}"
|
communication.sending_result = f"Request error: {e}"
|
||||||
else:
|
else:
|
||||||
communication.processing_result = f"Request error: {e}" else:
|
communication.processing_result = f"Request error: {e}"
|
||||||
|
else:
|
||||||
communication.sending_result = f"Unexpected error: {e}"
|
communication.sending_result = f"Unexpected error: {e}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user