콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
5098 화면

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
1418
0
4월 21
2346
4
5월 24
38686
1
3월 24
2782
2
12월 20
6344