Merge pull request #5931 from expsa/commited

commit constrain
This commit is contained in:
mohammed-alkhazrji 2026-01-01 17:46:06 +03:00 committed by GitHub
commit 3b98973e2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 20 deletions

View File

@ -341,26 +341,26 @@ class FamilyMemberProfile(models.Model):
"Death Certificate is required for member '%s' when marked as deceased."
) % rec.name)
@api.constrains('is_work', 'age', 'member_income', 'salary_certificate')
def _check_salary_certificate_required(self):
for rec in self:
if rec.age >= 18 and rec.is_work:
if rec.member_income <= 0:
raise ValidationError(_(
"Income must be greater than 0 for member '%s' when working and age is greater than or equal to 18."
) % rec.name)
if not rec.salary_certificate:
raise ValidationError(_(
"Salary Certificate is required for member '%s' when working and age is greater than or equal to 18."
) % rec.name)
@api.constrains('is_mother', 'is_married', 'marriage_certificate')
def _check_marriage_certificate_required(self):
for rec in self:
if not rec.is_mother and rec.is_married and not rec.marriage_certificate:
raise ValidationError(_(
"Marriage Certificate is required for member '%s' when marked as married and not a mother."
) % rec.name)
# @api.constrains('is_work', 'age', 'member_income', 'salary_certificate')
# def _check_salary_certificate_required(self):
# for rec in self:
# if rec.age >= 18 and rec.is_work:
# if rec.member_income <= 0:
# raise ValidationError(_(
# "Income must be greater than 0 for member '%s' when working and age is greater than or equal to 18."
# ) % rec.name)
# if not rec.salary_certificate:
# raise ValidationError(_(
# "Salary Certificate is required for member '%s' when working and age is greater than or equal to 18."
# ) % rec.name)
#
# @api.constrains('is_mother', 'is_married', 'marriage_certificate')
# def _check_marriage_certificate_required(self):
# for rec in self:
# if not rec.is_mother and rec.is_married and not rec.marriage_certificate:
# raise ValidationError(_(
# "Marriage Certificate is required for member '%s' when marked as married and not a mother."
# ) % rec.name)
@api.constrains('member_first_name')
def _check_names_alphabetic(self):