[IMP] pms: assure coherence between residence state and residence country (checkin partner & partner)

This commit is contained in:
miguelpadin
2024-09-05 09:12:24 +01:00
parent 7e13e6b848
commit fd37f63776
2 changed files with 26 additions and 0 deletions

View File

@@ -750,6 +750,19 @@ class PmsCheckinPartner(models.Model):
_("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
def create(self, vals):
# The checkin records are created automatically from adult depends

View File

@@ -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):
self.ensure_one()
partner = False