跳至內容
選單
此問題已被標幟
2107 瀏覽次數

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

頭像
捨棄
作者

@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")