mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[REF]pms_l10n_es: refactoring of the wizards and tests of the INE and traveler_report
This commit is contained in:
@@ -97,6 +97,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner1",
|
||||
"country_id": self.country_italy.id,
|
||||
"nationality_id": self.country_italy.id,
|
||||
"residence_country_id": self.country_italy.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -116,6 +117,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner2",
|
||||
"country_id": self.country_russia.id,
|
||||
"nationality_id": self.country_russia.id,
|
||||
"residence_country_id": self.country_russia.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -134,6 +136,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner3",
|
||||
"country_id": self.country_italy.id,
|
||||
"nationality_id": self.country_italy.id,
|
||||
"residence_country_id": self.country_italy.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -152,6 +155,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner4",
|
||||
"country_id": self.country_italy.id,
|
||||
"nationality_id": self.country_italy.id,
|
||||
"residence_country_id": self.country_italy.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -170,6 +174,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner5",
|
||||
"country_id": self.country_afghanistan.id,
|
||||
"nationality_id": self.country_afghanistan.id,
|
||||
"residence_country_id": self.country_afghanistan.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -188,6 +193,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner6",
|
||||
"country_id": self.country_afghanistan.id,
|
||||
"nationality_id": self.country_afghanistan.id,
|
||||
"residence_country_id": self.country_afghanistan.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -206,6 +212,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner7",
|
||||
"country_id": self.country_afghanistan.id,
|
||||
"nationality_id": self.country_afghanistan.id,
|
||||
"residence_country_id": self.country_afghanistan.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -364,6 +371,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner1",
|
||||
"country_id": self.country_russia.id,
|
||||
"nationality_id": self.country_russia.id,
|
||||
"residence_country_id": self.country_russia.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -373,6 +381,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner2",
|
||||
"country_id": self.country_russia.id,
|
||||
"nationality_id": self.country_russia.id,
|
||||
"residence_country_id": self.country_russia.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -382,6 +391,7 @@ class TestWizardINE(TestPms):
|
||||
"name": "partner3",
|
||||
"country_id": self.country_russia.id,
|
||||
"nationality_id": self.country_russia.id,
|
||||
"residence_country_id": self.country_russia.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -644,40 +654,40 @@ class TestWizardINE(TestPms):
|
||||
[("name", "=", "Pontevedra")]
|
||||
)
|
||||
|
||||
self.checkin1.nationality_id = country_spain
|
||||
self.partner_1.nationality_id = country_spain
|
||||
self.checkin1.state_id = state_ourense
|
||||
self.partner_1.state_id = state_ourense
|
||||
self.checkin1.residence_country_id = country_spain
|
||||
self.partner_1.residence_country_id = country_spain
|
||||
self.checkin1.residence_state_id = state_ourense
|
||||
self.partner_1.residence_state_id = state_ourense
|
||||
|
||||
self.checkin2.nationality_id = country_spain
|
||||
self.partner_2.nationality_id = country_spain
|
||||
self.checkin2.state_id = state_pontevedra
|
||||
self.partner_2.state_id = state_pontevedra
|
||||
self.checkin2.residence_country_id = country_spain
|
||||
self.partner_2.residence_country_id = country_spain
|
||||
self.checkin2.residence_state_id = state_pontevedra
|
||||
self.partner_2.residence_state_id = state_pontevedra
|
||||
|
||||
self.checkin3.nationality_id = country_spain
|
||||
self.partner_3.nationality_id = country_spain
|
||||
self.checkin3.state_id = state_ourense
|
||||
self.partner_3.state_id = state_ourense
|
||||
self.checkin3.residence_country_id = country_spain
|
||||
self.partner_3.residence_country_id = country_spain
|
||||
self.checkin3.residence_state_id = state_ourense
|
||||
self.partner_3.residence_state_id = state_ourense
|
||||
|
||||
self.checkin4.nationality_id = country_spain
|
||||
self.partner_4.nationality_id = country_spain
|
||||
self.checkin4.state_id = state_ourense
|
||||
self.partner_4.state_id = state_ourense
|
||||
self.checkin4.residence_country_id = country_spain
|
||||
self.partner_4.residence_country_id = country_spain
|
||||
self.checkin4.residence_state_id = state_ourense
|
||||
self.partner_4.residence_state_id = state_ourense
|
||||
|
||||
self.checkin5.nationality_id = country_spain
|
||||
self.partner_5.nationality_id = country_spain
|
||||
self.checkin5.state_id = state_madrid
|
||||
self.partner_5.state_id = state_madrid
|
||||
self.checkin5.residence_country_id = country_spain
|
||||
self.partner_5.residence_country_id = country_spain
|
||||
self.checkin5.residence_state_id = state_madrid
|
||||
self.partner_5.residence_state_id = state_madrid
|
||||
|
||||
self.checkin6.nationality_id = country_spain
|
||||
self.partner_6.nationality_id = country_spain
|
||||
self.checkin6.state_id = state_madrid
|
||||
self.partner_6.state_id = state_madrid
|
||||
self.checkin6.residence_country_id = country_spain
|
||||
self.partner_6.residence_country_id = country_spain
|
||||
self.checkin6.residence_state_id = state_madrid
|
||||
self.partner_6.residence_state_id = state_madrid
|
||||
|
||||
self.checkin7.nationality_id = country_spain
|
||||
self.partner_7.nationality_id = country_spain
|
||||
self.checkin7.state_id = state_madrid
|
||||
self.partner_7.state_id = state_madrid
|
||||
self.checkin7.residence_country_id = country_spain
|
||||
self.partner_7.residence_country_id = country_spain
|
||||
self.checkin7.residence_state_id = state_madrid
|
||||
self.partner_7.residence_state_id = state_madrid
|
||||
|
||||
expected_result = {
|
||||
country_spain.code: {
|
||||
@@ -888,7 +898,7 @@ class TestWizardINE(TestPms):
|
||||
"""
|
||||
# ARRANGE
|
||||
self.ideal_scenario()
|
||||
self.partner_2.nationality_id = False
|
||||
self.partner_2.residence_country_id = False
|
||||
start_date = datetime.date(2021, 2, 1)
|
||||
end_date = datetime.date(2021, 2, 4)
|
||||
|
||||
@@ -943,40 +953,40 @@ class TestWizardINE(TestPms):
|
||||
[("name", "=", "Ourense (Orense)")]
|
||||
)
|
||||
|
||||
self.checkin1.nationality_id = country_spain
|
||||
self.partner_1.nationality_id = country_spain
|
||||
self.checkin1.state_id = state_ourense
|
||||
self.partner_1.state_id = state_ourense
|
||||
self.checkin1.residence_country_id = country_spain
|
||||
self.partner_1.residence_country_id = country_spain
|
||||
self.checkin1.residence_state_id = state_ourense
|
||||
self.partner_1.residence_state_id = state_ourense
|
||||
|
||||
self.checkin2.nationality_id = country_spain
|
||||
self.partner_2.nationality_id = country_spain
|
||||
self.checkin2.state_id = False
|
||||
self.partner_2.state_id = False
|
||||
self.checkin2.residence_country_id = country_spain
|
||||
self.partner_2.residence_country_id = country_spain
|
||||
self.checkin2.residence_state_id = False
|
||||
self.partner_2.residence_state_id = False
|
||||
|
||||
self.checkin3.nationality_id = country_spain
|
||||
self.partner_3.nationality_id = country_spain
|
||||
self.checkin3.state_id = state_ourense
|
||||
self.partner_3.state_id = state_ourense
|
||||
self.checkin3.residence_country_id = country_spain
|
||||
self.partner_3.residence_country_id = country_spain
|
||||
self.checkin3.residence_state_id = state_ourense
|
||||
self.partner_3.residence_state_id = state_ourense
|
||||
|
||||
self.checkin4.nationality_id = country_spain
|
||||
self.partner_4.nationality_id = country_spain
|
||||
self.checkin4.state_id = state_ourense
|
||||
self.partner_4.state_id = state_ourense
|
||||
self.checkin4.residence_country_id = country_spain
|
||||
self.partner_4.residence_country_id = country_spain
|
||||
self.checkin4.residence_state_id = state_ourense
|
||||
self.partner_4.residence_state_id = state_ourense
|
||||
|
||||
self.checkin5.nationality_id = country_spain
|
||||
self.partner_5.nationality_id = country_spain
|
||||
self.checkin5.state_id = state_madrid
|
||||
self.partner_5.state_id = state_madrid
|
||||
self.checkin5.residence_country_id = country_spain
|
||||
self.partner_5.residence_country_id = country_spain
|
||||
self.checkin5.residence_state_id = state_madrid
|
||||
self.partner_5.residence_state_id = state_madrid
|
||||
|
||||
self.checkin6.nationality_id = country_spain
|
||||
self.partner_6.nationality_id = country_spain
|
||||
self.checkin6.state_id = state_madrid
|
||||
self.partner_6.state_id = state_madrid
|
||||
self.checkin6.residence_country_id = country_spain
|
||||
self.partner_6.residence_country_id = country_spain
|
||||
self.checkin6.residence_state_id = state_madrid
|
||||
self.partner_6.residence_state_id = state_madrid
|
||||
|
||||
self.checkin7.nationality_id = country_spain
|
||||
self.partner_7.nationality_id = country_spain
|
||||
self.checkin7.state_id = state_madrid
|
||||
self.partner_7.state_id = state_madrid
|
||||
self.checkin7.residence_country_id = country_spain
|
||||
self.partner_7.residence_country_id = country_spain
|
||||
self.checkin7.residence_state_id = state_madrid
|
||||
self.partner_7.residence_state_id = state_madrid
|
||||
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(
|
||||
|
||||
@@ -56,6 +56,7 @@ class TestWizardTravellerReport(TestPms):
|
||||
"name": "partner1",
|
||||
"country_id": self.country_italy.id,
|
||||
"nationality_id": self.country_italy.id,
|
||||
"residence_country_id": self.country_italy.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -75,6 +76,7 @@ class TestWizardTravellerReport(TestPms):
|
||||
"name": "partner2",
|
||||
"country_id": self.country_italy.id,
|
||||
"nationality_id": self.country_italy.id,
|
||||
"residence_country_id": self.country_italy.id,
|
||||
"birthdate_date": "2000-06-25",
|
||||
"gender": "male",
|
||||
}
|
||||
@@ -175,6 +177,7 @@ class TestWizardTravellerReport(TestPms):
|
||||
"reservation_id": self.reservation_1.id,
|
||||
"firstname": "John",
|
||||
"lastname": "Doe",
|
||||
"residence_country_id": self.country_italy.id,
|
||||
}
|
||||
)
|
||||
# Create reservation 2
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
>
|
||||
<xpath expr="//div[@name='document_type_div']" position="replace">
|
||||
<div t-attf-class="form-group col-md-4">
|
||||
<label
|
||||
class="col-form-label"
|
||||
for="document_type"
|
||||
>Doc. Type</label>
|
||||
<label class="col-form-label" for="document_type">Doc. Type</label>
|
||||
<div class="d-none"><p id="docTypeId"><t
|
||||
t-esc="checkin_partner_id.document_type"
|
||||
/></p></div>
|
||||
t-esc="checkin_partner_id.document_type"
|
||||
/></p></div>
|
||||
<select
|
||||
class="form-control #{error.get('document_type') and 'is-invalid' or ''}"
|
||||
name='document_type'
|
||||
@@ -37,10 +34,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='document_number_div']" position="replace">
|
||||
<div t-attf-class="col-12 col-md-4">
|
||||
<label
|
||||
class="col-form-label"
|
||||
for="document_number"
|
||||
>Doc. Number</label>
|
||||
<label class="col-form-label" for="document_number">Doc. Number</label>
|
||||
<input
|
||||
type="text"
|
||||
name="document_number"
|
||||
@@ -73,17 +67,11 @@
|
||||
inherit_id="pms.portal_my_precheckin_end"
|
||||
>
|
||||
<xpath expr="//div[@name='birthdate_div']" position="before">
|
||||
<div
|
||||
t-attf-class="form-group col-12 col-md-6 font-weight-bold"
|
||||
>
|
||||
<div t-attf-class="form-group col-12 col-md-6 font-weight-bold">
|
||||
Doc. Support Number:
|
||||
<br />
|
||||
<span
|
||||
class="font-weight-normal ml-3"
|
||||
>
|
||||
<t
|
||||
t-esc="checkin_partner.support_number"
|
||||
/>
|
||||
<span class="font-weight-normal ml-3">
|
||||
<t t-esc="checkin_partner.support_number" />
|
||||
</span>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
@@ -130,7 +130,7 @@ class TravellerReport(models.TransientModel):
|
||||
else:
|
||||
content += "M|"
|
||||
content += line.birthdate_date.strftime("%Y%m%d") + "|"
|
||||
content += line.nationality_id.name.upper() + "|"
|
||||
content += line.residence_country_id.name.upper() + "|"
|
||||
content += line.arrival.strftime("%Y%m%d") + "\n"
|
||||
|
||||
return content
|
||||
|
||||
@@ -197,7 +197,7 @@ class WizardIne(models.TransientModel):
|
||||
"""
|
||||
|
||||
for entry in read_group_result:
|
||||
if not entry["nationality_id"]:
|
||||
if not entry["residence_country_id"]:
|
||||
guests_with_no_nationality = self.env["res.partner"].search(
|
||||
entry["__domain"]
|
||||
)
|
||||
@@ -208,14 +208,14 @@ class WizardIne(models.TransientModel):
|
||||
)
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The following guests have no nationality set :%s.",
|
||||
"The following guests have no residence nationality set :%s.",
|
||||
guests_with_no_nationality,
|
||||
)
|
||||
)
|
||||
# get nationality_id from group set read_group results
|
||||
# get residence_country_id from group set read_group results
|
||||
nationality_id_code = (
|
||||
self.env["res.country"]
|
||||
.search([("id", "=", entry["nationality_id"][0])])
|
||||
.search([("id", "=", entry["residence_country_id"][0])])
|
||||
.code
|
||||
)
|
||||
# all countries except Spain
|
||||
@@ -234,13 +234,13 @@ class WizardIne(models.TransientModel):
|
||||
# arrivals grouped by state_id (Spain "provincias")
|
||||
read_by_arrivals_spain = self.env["res.partner"].read_group(
|
||||
entry["__domain"],
|
||||
["state_id"],
|
||||
["state_id"],
|
||||
["residence_state_id"],
|
||||
["residence_state_id"],
|
||||
lazy=False,
|
||||
)
|
||||
# iterate read_group results from Spain
|
||||
for entry_from_spain in read_by_arrivals_spain:
|
||||
if not entry_from_spain["state_id"]:
|
||||
if not entry_from_spain["residence_state_id"]:
|
||||
spanish_guests_with_no_state = self.env[
|
||||
"res.partner"
|
||||
].search(entry_from_spain["__domain"])
|
||||
@@ -256,7 +256,7 @@ class WizardIne(models.TransientModel):
|
||||
)
|
||||
)
|
||||
state_id = self.env["res.country.state"].browse(
|
||||
entry_from_spain["state_id"][0]
|
||||
entry_from_spain["residence_state_id"][0]
|
||||
) # .ine_code
|
||||
ine_code = state_id.ine_code
|
||||
|
||||
@@ -318,17 +318,17 @@ class WizardIne(models.TransientModel):
|
||||
if chk_part_same_reserv_with_checkin:
|
||||
# create partner with same country & state
|
||||
country_other = (
|
||||
chk_part_same_reserv_with_checkin.partner_id.country_id.id
|
||||
chk_part_same_reserv_with_checkin.partner_id.residence_country_id.id
|
||||
)
|
||||
state_other = (
|
||||
chk_part_same_reserv_with_checkin.partner_id.state_id.id
|
||||
chk_part_same_reserv_with_checkin.partner_id.residence_state_id.id
|
||||
)
|
||||
dummy_partner = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "partner1",
|
||||
"country_id": country_other,
|
||||
"nationality_id": country_other,
|
||||
"state_id": state_other,
|
||||
"residence_country_id": country_other,
|
||||
"residence_state_id": state_other,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -338,8 +338,8 @@ class WizardIne(models.TransientModel):
|
||||
{
|
||||
"name": "partner1",
|
||||
"country_id": country_spain.id,
|
||||
"nationality_id": country_spain.id,
|
||||
"state_id": state_madrid.id,
|
||||
"residence_country_id": country_spain.id,
|
||||
"residence_state_id": state_madrid.id,
|
||||
}
|
||||
)
|
||||
fake_partners_ids.append(dummy_partner.id)
|
||||
@@ -351,12 +351,12 @@ class WizardIne(models.TransientModel):
|
||||
# arrivals
|
||||
arrivals = hosts.filtered(lambda x: x.checkin == p_date)
|
||||
|
||||
# arrivals grouped by nationality_id
|
||||
# arrivals grouped by residence_country_id
|
||||
read_by_arrivals = self.env["res.partner"].read_group(
|
||||
[("id", "in", arrivals.mapped("partner_id").ids)],
|
||||
["nationality_id"],
|
||||
["nationality_id"],
|
||||
orderby="nationality_id",
|
||||
["residence_country_id"],
|
||||
["residence_country_id"],
|
||||
orderby="residence_country_id",
|
||||
lazy=False,
|
||||
)
|
||||
|
||||
@@ -366,21 +366,21 @@ class WizardIne(models.TransientModel):
|
||||
# departures grouped by nationality_id
|
||||
read_by_departures = self.env["res.partner"].read_group(
|
||||
[("id", "in", departures.mapped("partner_id").ids)],
|
||||
["nationality_id"],
|
||||
["nationality_id"],
|
||||
orderby="nationality_id",
|
||||
["residence_country_id"],
|
||||
["residence_country_id"],
|
||||
orderby="residence_country_id",
|
||||
lazy=False,
|
||||
)
|
||||
|
||||
# pernoctations
|
||||
pernoctations = hosts - departures
|
||||
|
||||
# pernoctations grouped by nationality_id
|
||||
# pernoctations grouped by residence_country_id
|
||||
read_by_pernoctations = self.env["res.partner"].read_group(
|
||||
[("id", "in", pernoctations.mapped("partner_id").ids)],
|
||||
["nationality_id"],
|
||||
["nationality_id"],
|
||||
orderby="nationality_id",
|
||||
["residence_country_id"],
|
||||
["residence_country_id"],
|
||||
orderby="residence_country_id",
|
||||
lazy=False,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user