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

Hello every one,

i want check a lead type is 'lead' or 'opportunity'? from crm_lead table.

here is my code,

def _check_lead(self, cr, uid, ids, fields, args, context=None):
            for lead in self.browse(cr, uid, ids, type, context=context):

                if lead.type == 'lead':

                    print "type is lead"

                else:

                    print "type is opportunity"

please correct my code,

 

thanks in advance,

 

 

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

You should always use browse() and not read() It has a better performance and his object oriented.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

If you will still use browse as intended, then remove the 'type' argument from the call, as well as the context, i.e.:

for lead in self.browse(cr, uid, ids):

[EDIT]

@Fabien: I have removed the read. Apparantly the difference is now negligible.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 15
4899
1
มี.ค. 15
5705
What are the main concepts used in CRM? แก้ไขแล้ว
1
มี.ค. 15
5744
2
ก.พ. 24
1982
2
ส.ค. 25
952