mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] pms-l10n_es: fix mandatory fields for childrens
This commit is contained in:
@@ -452,6 +452,7 @@ class PmsCheckinPartner(models.Model):
|
||||
for field in record._checkin_mandatory_fields(
|
||||
residence_country=record.residence_country_id,
|
||||
document_type=record.document_type,
|
||||
birthdate_date=record.birthdate_date,
|
||||
)
|
||||
):
|
||||
record.state = "draft"
|
||||
@@ -782,7 +783,7 @@ class PmsCheckinPartner(models.Model):
|
||||
dummy_checkins = reservation.checkin_partner_ids.filtered(
|
||||
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)
|
||||
if len(dummy_checkins) > 0:
|
||||
dummy_checkins[0].write(vals)
|
||||
@@ -819,6 +820,10 @@ class PmsCheckinPartner(models.Model):
|
||||
"residence_city",
|
||||
"residence_country_id",
|
||||
"residence_state_id",
|
||||
"document_country_id",
|
||||
"document_type",
|
||||
|
||||
|
||||
]
|
||||
return manual_fields
|
||||
|
||||
@@ -833,7 +838,7 @@ class PmsCheckinPartner(models.Model):
|
||||
self, residence_country=False, document_type=False, birthdate_date=False
|
||||
):
|
||||
mandatory_fields = [
|
||||
"name",
|
||||
"firstname",
|
||||
]
|
||||
return mandatory_fields
|
||||
|
||||
|
||||
@@ -85,8 +85,8 @@ class PmsCheckinPartner(models.Model):
|
||||
]
|
||||
)
|
||||
|
||||
# Checkins with age greater than 14 must have an identity document
|
||||
if birthdate_date:
|
||||
# Checkins with age greater than 14 must have an identity document
|
||||
if birthdate_date <= fields.Date.today() - relativedelta(years=14):
|
||||
mandatory_fields.extend(
|
||||
[
|
||||
@@ -96,6 +96,14 @@ class PmsCheckinPartner(models.Model):
|
||||
"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:
|
||||
mandatory_fields.extend(
|
||||
@@ -120,7 +128,13 @@ class PmsCheckinPartner(models.Model):
|
||||
@api.model
|
||||
def _checkin_manual_fields(self, country=False):
|
||||
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
|
||||
|
||||
def get_document_vals(self):
|
||||
|
||||
Reference in New Issue
Block a user