Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
5665 Weergaven

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,

 

 

Avatar
Annuleer
Auteur Beste antwoord

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

Avatar
Annuleer
Beste antwoord

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.

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
mrt. 15
4877
1
mrt. 15
5669
1
mrt. 15
5685
2
feb. 24
1942
2
aug. 25
925