mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms_l10n_es: improvements in traveller reports
This commit is contained in:
@@ -6,7 +6,7 @@ class PmsLogInstitutionTravellerReport(models.Model):
|
|||||||
_description = "Report of daily sending files of travellers to institutions."
|
_description = "Report of daily sending files of travellers to institutions."
|
||||||
|
|
||||||
date = fields.Datetime(
|
date = fields.Datetime(
|
||||||
string="Date and time",
|
string="Send Date",
|
||||||
default=fields.Datetime.now,
|
default=fields.Datetime.now,
|
||||||
)
|
)
|
||||||
error_sending_data = fields.Boolean(
|
error_sending_data = fields.Boolean(
|
||||||
@@ -21,3 +21,10 @@ class PmsLogInstitutionTravellerReport(models.Model):
|
|||||||
)
|
)
|
||||||
txt_filename = fields.Text()
|
txt_filename = fields.Text()
|
||||||
txt_message = fields.Char(string="Log Message")
|
txt_message = fields.Char(string="Log Message")
|
||||||
|
pms_property_id = fields.Many2one(
|
||||||
|
comodel_name="pms.property",
|
||||||
|
string="Property",
|
||||||
|
)
|
||||||
|
target_date = fields.Date(
|
||||||
|
string="Checkins Date",
|
||||||
|
)
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
filename="txt_filename"
|
filename="txt_filename"
|
||||||
readonly="1"
|
readonly="1"
|
||||||
/>
|
/>
|
||||||
|
<field name="target_date" />
|
||||||
|
<field name="pms_property_id" />
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
@@ -40,9 +42,24 @@
|
|||||||
readonly="1"
|
readonly="1"
|
||||||
string="Size"
|
string="Size"
|
||||||
/>
|
/>
|
||||||
|
<field name="target_date" />
|
||||||
|
<field name="pms_property_id" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="pms_log_institution_traveller_report_view_search">
|
||||||
|
<field name="name">pms.log.institution.traveller.report.search</field>
|
||||||
|
<field name="model">pms.log.institution.traveller.report</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="Log institution traveller report">
|
||||||
|
<field name="date" />
|
||||||
|
<field name="target_date" />
|
||||||
|
<field name="pms_property_id" />
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record
|
<record
|
||||||
model="ir.actions.act_window"
|
model="ir.actions.act_window"
|
||||||
id="open_pms_log_institution_traveller_report_form_tree"
|
id="open_pms_log_institution_traveller_report_form_tree"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import base64
|
|||||||
import datetime
|
import datetime
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import PyPDF2
|
import PyPDF2
|
||||||
@@ -71,6 +72,7 @@ class TravellerReport(models.TransientModel):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def generate_checkin_list(self, property_id, date_target=False):
|
def generate_checkin_list(self, property_id, date_target=False):
|
||||||
|
regex = re.compile("[^a-zA-Z0-9]")
|
||||||
if not date_target:
|
if not date_target:
|
||||||
date_target = fields.date.today()
|
date_target = fields.date.today()
|
||||||
# check if there's guests info pending to send
|
# check if there's guests info pending to send
|
||||||
@@ -101,7 +103,7 @@ class TravellerReport(models.TransientModel):
|
|||||||
"1|"
|
"1|"
|
||||||
+ pms_property.institution_property_id.upper()
|
+ pms_property.institution_property_id.upper()
|
||||||
+ "|"
|
+ "|"
|
||||||
+ pms_property.name.upper()
|
+ regex.sub(" ", pms_property.name.upper())
|
||||||
+ "|"
|
+ "|"
|
||||||
+ datetime.datetime.now().strftime("%Y%m%d|%H%M")
|
+ datetime.datetime.now().strftime("%Y%m%d|%H%M")
|
||||||
+ "|"
|
+ "|"
|
||||||
@@ -115,16 +117,16 @@ class TravellerReport(models.TransientModel):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
content += "2"
|
content += "2"
|
||||||
# [P|N|..]
|
# [P|N|..]
|
||||||
if line.document_type.code != "D":
|
if line.document_type.code not in ["D", "C"]:
|
||||||
content += "||" + line.document_number.upper() + "|"
|
content += "||" + regex.sub("", line.document_number.upper()) + "|"
|
||||||
else:
|
else:
|
||||||
content += "|" + line.document_number.upper() + "||"
|
content += "|" + regex.sub("", line.document_number.upper()) + "||"
|
||||||
content += line.document_type.code + "|"
|
content += line.document_type.code + "|"
|
||||||
content += line.document_expedition_date.strftime("%Y%m%d") + "|"
|
content += line.document_expedition_date.strftime("%Y%m%d") + "|"
|
||||||
content += line.lastname.upper() + "|"
|
content += regex.sub(" ", line.lastname.upper()) + "|"
|
||||||
if line.lastname2:
|
if line.lastname2:
|
||||||
content += line.lastname2.upper()
|
content += regex.sub(" ", line.lastname2.upper())
|
||||||
content += "|" + line.firstname.upper() + "|"
|
content += "|" + regex.sub(" ", line.firstname.upper()) + "|"
|
||||||
if line.gender == "female":
|
if line.gender == "female":
|
||||||
content += "F|"
|
content += "F|"
|
||||||
else:
|
else:
|
||||||
@@ -140,7 +142,7 @@ class TravellerReport(models.TransientModel):
|
|||||||
login_route = "/hospederias/login.do"
|
login_route = "/hospederias/login.do"
|
||||||
upload_file_route = "/hospederias/cargaFichero.do"
|
upload_file_route = "/hospederias/cargaFichero.do"
|
||||||
logout_route = "/hospederias/logout.do"
|
logout_route = "/hospederias/logout.do"
|
||||||
|
target_date = self.date_target or fields.date.today()
|
||||||
if file_content:
|
if file_content:
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 "
|
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 "
|
||||||
@@ -204,6 +206,8 @@ class TravellerReport(models.TransientModel):
|
|||||||
{
|
{
|
||||||
"error_sending_data": True,
|
"error_sending_data": True,
|
||||||
"txt_incidencies_from_institution": msg,
|
"txt_incidencies_from_institution": msg,
|
||||||
|
"pms_property_id": pms_property.id,
|
||||||
|
"target_date": target_date,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
raise ValidationError(msg)
|
raise ValidationError(msg)
|
||||||
@@ -223,6 +227,8 @@ class TravellerReport(models.TransientModel):
|
|||||||
"message": _("Successful file sending"),
|
"message": _("Successful file sending"),
|
||||||
"sticky": False,
|
"sticky": False,
|
||||||
},
|
},
|
||||||
|
"pms_property_id": pms_property.id,
|
||||||
|
"target_date": target_date,
|
||||||
}
|
}
|
||||||
return message
|
return message
|
||||||
|
|
||||||
@@ -243,7 +249,7 @@ class TravellerReport(models.TransientModel):
|
|||||||
files_sent_list_route = "/e-hotel/hospederia/listar/ficherosHospederia"
|
files_sent_list_route = "/e-hotel/hospederia/listar/ficherosHospederia"
|
||||||
last_file_errors_route = "/e-hotel/hospederia/report/erroresFicheroHospederia"
|
last_file_errors_route = "/e-hotel/hospederia/report/erroresFicheroHospederia"
|
||||||
logout_route = "/e-hotel/execute_logout"
|
logout_route = "/e-hotel/execute_logout"
|
||||||
|
target_date = self.date_target or fields.date.today()
|
||||||
session = requests.session()
|
session = requests.session()
|
||||||
|
|
||||||
# retrieve token
|
# retrieve token
|
||||||
@@ -434,6 +440,8 @@ class TravellerReport(models.TransientModel):
|
|||||||
response_last_file_errors_route.content
|
response_last_file_errors_route.content
|
||||||
),
|
),
|
||||||
"txt_filename": file_name + ".pdf",
|
"txt_filename": file_name + ".pdf",
|
||||||
|
"pms_property_id": pms_property.id,
|
||||||
|
"target_date": target_date,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -463,7 +471,7 @@ class TravellerReport(models.TransientModel):
|
|||||||
if not pms_property:
|
if not pms_property:
|
||||||
called_from_user = True
|
called_from_user = True
|
||||||
pms_property = self.env["pms.property"].search(
|
pms_property = self.env["pms.property"].search(
|
||||||
[("id", "=", self.env.user.get_active_property_ids()[0])]
|
[("id", "=", self.pms_property_id.id)]
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
not pms_property
|
not pms_property
|
||||||
|
|||||||
Reference in New Issue
Block a user