hi all
i need to create unique python constraint (by convert this sql constraint) to be applied for all records
_sql_constraints = [
('unique_mobile', 'unique (mobile)', 'Mobile number already exists!')
]
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hi all
i need to create unique python constraint (by convert this sql constraint) to be applied for all records
_sql_constraints = [
('unique_mobile', 'unique (mobile)', 'Mobile number already exists!')
]
Thanks
i found a solution
# Mobile Field to be unique
@api.constrains('mobile')
def _check_mobile_unique(self):
mobile_counts = self.search_count([('mobile', '=', self.mobile), ('id', '!=', self.id)])
print(mobile_counts)
if mobile_counts > 0:
raise ValidationError("Mobile number already exists!")
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
RegistratiPost correlati | Risposte | Visualizzazioni | Attività | |
---|---|---|---|---|
|
5
ott 24
|
32645 | ||
|
1
lug 23
|
7292 | ||
|
2
lug 22
|
11485 | ||
|
2
ott 21
|
3283 | ||
|
0
ago 21
|
2022 |