mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] pms-l10n_es: fix percentages @ ine report
This commit is contained in:
@@ -652,7 +652,7 @@ class TestWizardINE(TestPms):
|
||||
},
|
||||
}
|
||||
# ACT
|
||||
nationalities = self.env["pms.ine.wizard"].ine_nationalities(
|
||||
nationalities = self.env["pms.ine.wizard"].ine_countries(
|
||||
start_date, end_date, self.pms_property1.id
|
||||
)
|
||||
# ASSERT
|
||||
@@ -778,7 +778,7 @@ class TestWizardINE(TestPms):
|
||||
}
|
||||
}
|
||||
# ACT
|
||||
nationalities = self.env["pms.ine.wizard"].ine_nationalities(
|
||||
nationalities = self.env["pms.ine.wizard"].ine_countries(
|
||||
start_date, end_date, self.pms_property1.id
|
||||
)
|
||||
# ASSERT
|
||||
@@ -910,7 +910,7 @@ class TestWizardINE(TestPms):
|
||||
},
|
||||
}
|
||||
# ACT
|
||||
nationalities = self.env["pms.ine.wizard"].ine_nationalities(
|
||||
nationalities = self.env["pms.ine.wizard"].ine_countries(
|
||||
start_date, end_date, self.pms_property1.id
|
||||
)
|
||||
# ASSERT
|
||||
@@ -956,7 +956,7 @@ class TestWizardINE(TestPms):
|
||||
ValidationError,
|
||||
msg="Cannot generate INE if some checkin partner has no nationality",
|
||||
):
|
||||
self.env["pms.ine.wizard"].ine_nationalities(
|
||||
self.env["pms.ine.wizard"].ine_countries(
|
||||
start_date, end_date, self.pms_property1.id
|
||||
)
|
||||
|
||||
@@ -1042,6 +1042,6 @@ class TestWizardINE(TestPms):
|
||||
ValidationError,
|
||||
msg="Cannot generate INE if some checkin partner from Spain has no nationality",
|
||||
):
|
||||
self.env["pms.ine.wizard"].ine_nationalities(
|
||||
self.env["pms.ine.wizard"].ine_countries(
|
||||
start_date, end_date, self.pms_property1.id
|
||||
)
|
||||
|
||||
@@ -12,7 +12,6 @@ import zipfile
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import MissingError, ValidationError
|
||||
@@ -34,7 +33,7 @@ CREATE_OPERATION_CODE = "A"
|
||||
DELETE_OPERATION_CODE = "B"
|
||||
|
||||
# Disable insecure request warnings
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
# requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
|
||||
def _string_to_zip_to_base64(string_data):
|
||||
@@ -304,15 +303,21 @@ def _handle_request_exception(communication, e):
|
||||
if isinstance(e, requests.exceptions.RequestException):
|
||||
if isinstance(e, requests.exceptions.ConnectionError):
|
||||
if communication.state == "to_send":
|
||||
communication.sending_result = "Cannot establish the connection."
|
||||
else:
|
||||
communication.processing_result = "Cannot establish the connection."
|
||||
elif isinstance(e, requests.exceptions.Timeout):
|
||||
if communication.state == "to_send":
|
||||
communication.sending_result = "The request took too long to complete."
|
||||
communication.sending_result = (
|
||||
f"Cannot establish the connection. ({e.args})"
|
||||
)
|
||||
else:
|
||||
communication.processing_result = (
|
||||
"The request took too long to complete."
|
||||
f"Cannot establish the connection. ({e.args})"
|
||||
)
|
||||
elif isinstance(e, requests.exceptions.Timeout):
|
||||
if communication.state == "to_send":
|
||||
communication.sending_result = (
|
||||
f"The request took too long to complete. ({e.args})"
|
||||
)
|
||||
else:
|
||||
communication.processing_result = (
|
||||
f"The request took too long to complete. ({e.args})"
|
||||
)
|
||||
else:
|
||||
if communication.state == "to_send":
|
||||
@@ -1027,9 +1032,7 @@ class TravellerReport(models.TransientModel):
|
||||
communication.reservation_id.pms_property_id.ses_url,
|
||||
headers=_get_auth_headers(communication),
|
||||
data=payload,
|
||||
verify=get_module_resource(
|
||||
"pms_l10n_es", "static", "PRE_SGSICS.SES.MIR.ES.cer"
|
||||
),
|
||||
verify=get_module_resource("pms_l10n_es", "static", "ses_cert.pem"),
|
||||
)
|
||||
root = ET.fromstring(soap_response.text)
|
||||
communication.sending_result = root.find(".//descripcion").text
|
||||
@@ -1077,9 +1080,7 @@ class TravellerReport(models.TransientModel):
|
||||
communication.reservation_id.pms_property_id.ses_url,
|
||||
headers=_get_auth_headers(communication),
|
||||
data=payload,
|
||||
verify=get_module_resource(
|
||||
"pms_l10n_es", "static", "PRE_SGSICS.SES.MIR.ES.cer"
|
||||
),
|
||||
verify=get_module_resource("pms_l10n_es", "static", "cert.pem"),
|
||||
)
|
||||
root = ET.fromstring(soap_response.text)
|
||||
communication.response_communication_soap = soap_response.text
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import base64
|
||||
import calendar
|
||||
import datetime
|
||||
import math
|
||||
import xml.etree.cElementTree as ET
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
@@ -239,18 +240,18 @@ class WizardIne(models.TransientModel):
|
||||
|
||||
for entry in read_group_result:
|
||||
if not entry["residence_country_id"]:
|
||||
guests_with_no_nationality = self.env["pms.checkin.partner"].search(
|
||||
entry["__domain"]
|
||||
)
|
||||
guests_with_no_nationality = (
|
||||
str(guests_with_no_nationality.mapped("name"))
|
||||
guests_with_no_residence_country = self.env[
|
||||
"pms.checkin.partner"
|
||||
].search(entry["__domain"])
|
||||
guests_with_no_residence_country = (
|
||||
str(guests_with_no_residence_country.mapped("name"))
|
||||
.replace("[", "")
|
||||
.replace("]", "")
|
||||
)
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The following guests have no residence nationality set :%s.",
|
||||
guests_with_no_nationality,
|
||||
"The following guests have no residence country set :%s.",
|
||||
guests_with_no_residence_country,
|
||||
)
|
||||
)
|
||||
# get residence_country_id from group set read_group results
|
||||
@@ -739,8 +740,21 @@ class WizardIne(models.TransientModel):
|
||||
# so at least I will feel that the effort made some sense :)
|
||||
|
||||
total_percent = sum([val for val in percents.values()])
|
||||
sum_percentages = 0
|
||||
for group in total_groups_domains.keys():
|
||||
percents[group] = round(percents[group] * 100 / (total_percent or 1), 2)
|
||||
sum_percentages += percents[group]
|
||||
|
||||
if sum_percentages < 100:
|
||||
for group in total_groups_domains.keys():
|
||||
if percents[group] > 0:
|
||||
percents[group] += math.ceil((100 - sum_percentages) * 100) / 100
|
||||
break
|
||||
elif sum_percentages > 100:
|
||||
for group in total_groups_domains.keys():
|
||||
if percents[group] > 0:
|
||||
percents[group] -= math.ceil((sum_percentages - 100) * 100) / 100
|
||||
break
|
||||
|
||||
ET.SubElement(prices_tag, "ADR_TOUROPERADOR_TRADICIONAL").text = str(
|
||||
adrs["tour_operator_offline"]
|
||||
|
||||
Reference in New Issue
Block a user