Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4980 Näkymät

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

Avatar
Hylkää
Tekijä Paras vastaus

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

Avatar
Hylkää

Yes, why don't you try it now XD

Tekijä

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

Paras vastaus

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

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
helmik. 25
1236
0
huhtik. 21
2216
4
toukok. 24
38475
1
maalisk. 24
2650
2
jouluk. 20
6174