mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
@@ -750,6 +750,19 @@ class PmsCheckinPartner(models.Model):
|
|||||||
_("Document type and country of document do not match")
|
_("Document type and country of document do not match")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.constrains("residence_state_id", "residence_country_id")
|
||||||
|
def _check_residence_state_id_residence_country_id_consistence(self):
|
||||||
|
for record in self:
|
||||||
|
if record.residence_state_id and record.residence_country_id:
|
||||||
|
if (
|
||||||
|
record.residence_state_id.country_id
|
||||||
|
and record.residence_country_id
|
||||||
|
not in record.residence_state_id.country_id
|
||||||
|
):
|
||||||
|
raise ValidationError(
|
||||||
|
_("State and country of residence do not match")
|
||||||
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
# The checkin records are created automatically from adult depends
|
# The checkin records are created automatically from adult depends
|
||||||
|
|||||||
@@ -685,6 +685,19 @@ class ResPartner(models.Model):
|
|||||||
# )
|
# )
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
@api.constrains("residence_state_id", "residence_country_id")
|
||||||
|
def _check_residence_state_id_residence_country_id_consistence(self):
|
||||||
|
for record in self:
|
||||||
|
if record.residence_state_id and record.residence_country_id:
|
||||||
|
if (
|
||||||
|
record.residence_state_id.country_id
|
||||||
|
and record.residence_country_id
|
||||||
|
not in record.residence_state_id.country_id
|
||||||
|
):
|
||||||
|
raise ValidationError(
|
||||||
|
_("State and country of residence do not match")
|
||||||
|
)
|
||||||
|
|
||||||
def _search_duplicated(self):
|
def _search_duplicated(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
partner = False
|
partner = False
|
||||||
|
|||||||
@@ -1558,10 +1558,10 @@ class TestPmsCheckinPartner(TestPms):
|
|||||||
"sale_channel_origin_id": self.sale_channel_direct1.id,
|
"sale_channel_origin_id": self.sale_channel_direct1.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
checkin_partner_id = self.reservation.checkin_partner_ids[0]
|
checkin_partner = self.reservation.checkin_partner_ids[0]
|
||||||
checkin_partner_vals = {
|
checkin_partner_vals = {
|
||||||
"checkin_partner": checkin_partner_id,
|
"checkin_partner": checkin_partner,
|
||||||
"id": checkin_partner_id.id,
|
"id": checkin_partner.id,
|
||||||
"firstname": "Serafín",
|
"firstname": "Serafín",
|
||||||
"lastname": "Rivas",
|
"lastname": "Rivas",
|
||||||
"lastname2": "Gonzalez",
|
"lastname2": "Gonzalez",
|
||||||
@@ -1575,7 +1575,7 @@ class TestPmsCheckinPartner(TestPms):
|
|||||||
"nationality_id": 1,
|
"nationality_id": 1,
|
||||||
"residence_state_id": 1,
|
"residence_state_id": 1,
|
||||||
}
|
}
|
||||||
checkin_partner_id._save_data_from_portal(checkin_partner_vals)
|
checkin_partner._save_data_from_portal(checkin_partner_vals)
|
||||||
checkin_partner_vals.update(
|
checkin_partner_vals.update(
|
||||||
{
|
{
|
||||||
"birthdate_date": datetime.date(1983, 10, 5),
|
"birthdate_date": datetime.date(1983, 10, 5),
|
||||||
@@ -1615,9 +1615,14 @@ class TestPmsCheckinPartner(TestPms):
|
|||||||
"sale_channel_origin_id": self.sale_channel_direct1.id,
|
"sale_channel_origin_id": self.sale_channel_direct1.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
checkin_partner_id = self.reservation.checkin_partner_ids[0]
|
checkin_partner = self.reservation.checkin_partner_ids[0]
|
||||||
nationality_id = self.env["res.country"].browse(1)
|
nationality = self.env["res.country"].search(
|
||||||
state_id = self.env["res.country.state"].browse(1)
|
[
|
||||||
|
("state_ids", "!=", False),
|
||||||
|
],
|
||||||
|
limit=1,
|
||||||
|
)
|
||||||
|
state = nationality.state_ids[0]
|
||||||
partner_vals = {
|
partner_vals = {
|
||||||
"firstname": "Paz",
|
"firstname": "Paz",
|
||||||
"lastname": "Valenzuela",
|
"lastname": "Valenzuela",
|
||||||
@@ -1627,26 +1632,26 @@ class TestPmsCheckinPartner(TestPms):
|
|||||||
"gender": "female",
|
"gender": "female",
|
||||||
"mobile": "666555444",
|
"mobile": "666555444",
|
||||||
"phone": "123456789",
|
"phone": "123456789",
|
||||||
"nationality_id": nationality_id.id,
|
"nationality_id": nationality.id,
|
||||||
"residence_street": "Calle 123",
|
"residence_street": "Calle 123",
|
||||||
"residence_street2": "Avda. Constitución 123",
|
"residence_street2": "Avda. Constitución 123",
|
||||||
"residence_zip": "15700",
|
"residence_zip": "15700",
|
||||||
"residence_city": "City Residence",
|
"residence_city": "City Residence",
|
||||||
"residence_country_id": nationality_id.id,
|
"residence_country_id": nationality.id,
|
||||||
"residence_state_id": state_id.id,
|
"residence_state_id": state.id,
|
||||||
# "pms_checkin_partner_ids": checkin_partner_id,
|
# "pms_checkin_partner_ids": checkin_partner_id,
|
||||||
}
|
}
|
||||||
self.partner_id = self.env["res.partner"].create(partner_vals)
|
self.partner_id = self.env["res.partner"].create(partner_vals)
|
||||||
|
|
||||||
partner_vals.update(
|
partner_vals.update(
|
||||||
{
|
{
|
||||||
"nationality_id": nationality_id,
|
"nationality_id": nationality,
|
||||||
"residence_country_id": nationality_id,
|
"residence_country_id": nationality,
|
||||||
"residence_state_id": state_id,
|
"residence_state_id": state,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
checkin_partner_id.partner_id = self.partner_id.id
|
checkin_partner.partner_id = self.partner_id.id
|
||||||
for key in partner_vals:
|
for key in partner_vals:
|
||||||
if key != "pms_checkin_partner_ids":
|
if key != "pms_checkin_partner_ids":
|
||||||
with self.subTest(k=key):
|
with self.subTest(k=key):
|
||||||
|
|||||||
Reference in New Issue
Block a user