Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
6516 มุมมอง

Hi Folks,

I implemented odoo constraint in CRM model for mobile number and in contact module also for mobile number.

I punched 10 leads but when I try to convert lead into opportunity, 7/10 leads are perfectly converted but another 3 shows "mobile no. already exist" error.

I check my database table "res_partner" for particular mobile number but it is not there. I don't know why it returns "Mobile no. is already exists" even this was database table.

Any idea why it happened?

อวตาร
ละทิ้ง
ผู้เขียน

Got the issue. Actually I'm adding Contact Name and Company Name both in lead but in contact module it is consider as different contacts

คำตอบที่ดีที่สุด

Hi  Varinder Kaur,

Constrains will call only at the time of field values change, otherwise it will not be called.

My constraint code like below(it will be called while changing phone no. only)

@api.constrains('mobile')
def check_mobile_no(self):
if self.mobile:
record_count = self.search_count([('mobile', '=', self.mobile)])
# Need to mention Greater Than 1(Because self contains current record also)
if record_count > 1:
raise ValidationError("Mobile no. already exist.")

Thanks.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks Gokulakrishnan Murugesan sir!

It's working fine for Contact module but the problem occurs in CRM while converting Lead to Opportunity and selecting Create a new customer option meanwhile Mobile number is not present in Contact module but It return error.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 23
1667
2
พ.ค. 20
3664
7
ม.ค. 24
10885
0
พ.ย. 23
1257
How to create Customer programmatically? แก้ไขแล้ว
1
ธ.ค. 19
5646