Odoo Help


how to check a lead type is 'lead' or 'opportunity'?

on 5/23/14, 4:46 AM 1,098 views

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"


                    print "type is opportunity"

please correct my code,


thanks in advance,



On 5/26/14, 1:53 AM

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

Ludo - Neobis
On 5/23/14, 8:54 AM

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


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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/23/14, 4:46 AM
Seen: 1098 times
Last updated: 3/16/15, 8:10 AM