mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms: assure coherence between residence state and residence country (checkin partner & partner)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user