Odoo Help

Welcome!

This community 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.

0

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

By
Jothimani
on 5/23/14, 4:46 AM 775 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"

                else:

                    print "type is opportunity"

please correct my code,

 

thanks in advance,

 

 

1
Jothimani
On 5/26/14, 1:53 AM

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

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

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

[EDIT]

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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