[FIX] pms-l10n_es: fix mandatory fields for childrens

This commit is contained in:
miguelpadin
2024-12-16 11:06:39 +00:00
parent 43a75e5546
commit b72ac423c9
2 changed files with 23 additions and 4 deletions

View File

@@ -452,6 +452,7 @@ class PmsCheckinPartner(models.Model):
for field in record._checkin_mandatory_fields( for field in record._checkin_mandatory_fields(
residence_country=record.residence_country_id, residence_country=record.residence_country_id,
document_type=record.document_type, document_type=record.document_type,
birthdate_date=record.birthdate_date,
) )
): ):
record.state = "draft" record.state = "draft"
@@ -782,7 +783,7 @@ class PmsCheckinPartner(models.Model):
dummy_checkins = reservation.checkin_partner_ids.filtered( dummy_checkins = reservation.checkin_partner_ids.filtered(
lambda c: c.state == "dummy" lambda c: c.state == "dummy"
) )
if len(reservation.checkin_partner_ids) < reservation.adults: if len(reservation.checkin_partner_ids) < (reservation.adults + reservation.children):
return super(PmsCheckinPartner, self).create(vals) return super(PmsCheckinPartner, self).create(vals)
if len(dummy_checkins) > 0: if len(dummy_checkins) > 0:
dummy_checkins[0].write(vals) dummy_checkins[0].write(vals)
@@ -819,6 +820,10 @@ class PmsCheckinPartner(models.Model):
"residence_city", "residence_city",
"residence_country_id", "residence_country_id",
"residence_state_id", "residence_state_id",
"document_country_id",
"document_type",
] ]
return manual_fields return manual_fields
@@ -833,7 +838,7 @@ class PmsCheckinPartner(models.Model):
self, residence_country=False, document_type=False, birthdate_date=False self, residence_country=False, document_type=False, birthdate_date=False
): ):
mandatory_fields = [ mandatory_fields = [
"name", "firstname",
] ]
return mandatory_fields return mandatory_fields

View File

@@ -85,8 +85,8 @@ class PmsCheckinPartner(models.Model):
] ]
) )
# Checkins with age greater than 14 must have an identity document
if birthdate_date: if birthdate_date:
# Checkins with age greater than 14 must have an identity document
if birthdate_date <= fields.Date.today() - relativedelta(years=14): if birthdate_date <= fields.Date.today() - relativedelta(years=14):
mandatory_fields.extend( mandatory_fields.extend(
[ [
@@ -96,6 +96,14 @@ class PmsCheckinPartner(models.Model):
"document_country_id", "document_country_id",
] ]
) )
# Checkins with age lower than 18 must have a relationship with another checkin partner
if birthdate_date > fields.Date.today() - relativedelta(years=18):
mandatory_fields.extend(
[
"ses_partners_relationship",
"ses_related_checkin_partner_id",
]
)
if residence_country and residence_country.code == CODE_SPAIN: if residence_country and residence_country.code == CODE_SPAIN:
mandatory_fields.extend( mandatory_fields.extend(
@@ -120,7 +128,13 @@ class PmsCheckinPartner(models.Model):
@api.model @api.model
def _checkin_manual_fields(self, country=False): def _checkin_manual_fields(self, country=False):
manual_fields = super(PmsCheckinPartner, self)._checkin_manual_fields() manual_fields = super(PmsCheckinPartner, self)._checkin_manual_fields()
manual_fields.extend(["support_number"]) manual_fields.extend(
[
"support_number",
"ses_partners_relationship",
"ses_related_checkin_partner_id",
]
)
return manual_fields return manual_fields
def get_document_vals(self): def get_document_vals(self):