跳至内容
菜单
此问题已终结
2 回复
5659 查看

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.

形象
丢弃
相关帖文 回复 查看 活动
1
3月 15
4867
1
3月 15
5658
1
3月 15
5676
2
2月 24
1937
2
8月 25
912