Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2105 Lượt xem

The Passport and ID Number name must be unique for each country using api constrints, can you help me to solve this

Ảnh đại diện
Huỷ bỏ
Tác giả

@api.constrains('cpr','nationality')
def check_unique(self):
for record in self:
obj = self.search([('cpr','=',record.cpr),('id','!=',record.id)])
if obj:
raise ValidationError("The Passport and ID Number name must be unique for each country")