Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5609 Widoki

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,

 

 

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
mar 15
4829
1
mar 15
5628
1
mar 15
5606
2
lut 24
1901
2
sie 25
849