commit
17253025fd
|
|
@ -591,7 +591,7 @@ class GrantBenefitProfile(models.Model):
|
|||
]
|
||||
|
||||
def _expand_states(self, states, domain, order):
|
||||
return [key for key, val in type(self).state.selection]
|
||||
return [key for key, val in type(self).state.selection if key != 'draft']
|
||||
|
||||
@api.constrains('father_name', 'father_second_name', 'father_third_name', 'father_family_name',
|
||||
'mother_name', 'mother_second_name', 'mother_third_name', 'mother_family_name',
|
||||
|
|
@ -996,13 +996,29 @@ class GrantBenefitProfile(models.Model):
|
|||
raise ValidationError(_("The ID number %s in the Family Members list must be unique across the record.")%member.member_id_number)
|
||||
# Check for duplicate IDs across records in the database
|
||||
for id_number in unique_ids:
|
||||
duplicate_record_family = self.env['grant.benefit'].search([
|
||||
'|','|', ('father_id_number', '=', id_number), ('mother_id_number', '=', id_number),
|
||||
('replacement_mother_id_number', '=', id_number),('id','!=',self._origin.id)
|
||||
], limit=1)
|
||||
if id_number == self.father_id_number:
|
||||
conflict = self.env['grant.benefit'].search([
|
||||
('id', '!=', self._origin.id),
|
||||
'|', '|',
|
||||
('mother_id_number', '=', id_number),
|
||||
('replacement_mother_id_number', '=', id_number),
|
||||
], limit=1)
|
||||
if conflict:
|
||||
raise ValidationError(
|
||||
_("Father ID %s is already used in another family (as non-father) with code %s.") %
|
||||
(id_number, conflict.code))
|
||||
else:
|
||||
conflict = self.env['grant.benefit'].search([
|
||||
('id', '!=', self._origin.id),
|
||||
'|', '|', '|',
|
||||
('father_id_number', '=', id_number),
|
||||
('mother_id_number', '=', id_number),
|
||||
('replacement_mother_id_number', '=', id_number),
|
||||
], limit=1)
|
||||
if conflict:
|
||||
raise ValidationError(_("The ID number %s already exists in family with code %s.") %
|
||||
(id_number, conflict.code))
|
||||
duplicate_record_member = self.env['family.member'].search([('member_id_number', '=', id_number)], limit=1)
|
||||
if duplicate_record_family :
|
||||
raise ValidationError(_("The ID number {} already exists in family with code {}. Please enter a unique ID number.").format(id_number, duplicate_record_family.code))
|
||||
if duplicate_record_member :
|
||||
raise ValidationError(_("The ID number {} already exists in family with code {}. Please enter a unique ID number.").format(id_number, duplicate_record_member.code))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue