コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
5015 ビュー

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

アバター
破棄
著作者 最善の回答

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

アバター
破棄

Yes, why don't you try it now XD

著作者

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

最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
1
2月 25
1273
0
4月 21
2227
4
5月 24
38497
1
3月 24
2654
2
12月 20
6203