Skip to content

Commit

Permalink
Merge pull request #148 from Abhishek-Wagh/15.0-develop
Browse files Browse the repository at this point in the history
G2P-2169 Added validation for id type- it must be unique
  • Loading branch information
shibu-narayanan authored Jun 13, 2024
2 parents 9a89872 + e216418 commit 0ff6f9b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions g2p_registry_base/models/reg_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ def _onchange_id_validation(self):
f"The provided {rec.id_type.name} ID '{rec.value}' is invalid."
)

@api.constrains("partner_id", "id_type")
def _check_unique_id_type(self):
for record in self:
if (
self.search_count(
[
("partner_id", "=", record.partner_id.id),
("id_type", "=", record.id_type.id),
]
)
> 1
):
raise ValidationError(_("ID Type must be unique."))


class G2PIDType(models.Model):
_name = "g2p.id.type"
Expand Down

0 comments on commit 0ff6f9b

Please sign in to comment.