Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5004 Widoki

how can I check duplicate email when create new customers? Can anybody help me ? Thanks!

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Can I use sqlconstraints to check duplicate email like this? 

_sql_constraints = [ ('email_unique',   'UNIQUE(email)',   "The Email must be unique"), ]

Are you Vietnamese, Can you contact with me?
My email address: volamtruong01999@gmail.com

Awatar
Odrzuć

Yes, why don't you try it now XD

Autor

I was tried but it doesn't working for me

Try this

@api.constrains('email')

def _check_duplicate_email(self):

for rec in self:

emails = self.env['res.partner'].search([('email', '=', rec.email)])

for obj in emails:

if obj.email:

raise ValidationError("Duplicate Email")

Najlepsza odpowiedź

Hi, there are many ways

- Use Data Cleaning Apps (Odoo14 EE): It will find all duplicate records for you

- Use search bar (if you know which email is duplicated)

- Create a custom groupby for email field and find all the emails which have more than 1 record

- Create automated action (Odoo EE): and write python code to check the email field

- overwrite the create function of model res.partner

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lut 25
1269
0
kwi 21
2223
4
maj 24
38494
1
mar 24
2653
2
gru 20
6194