This question has been flagged
6 Replies
10542 Views

class lead_target(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(lead_target, self).__init__(cr, uid, name, context=context)
self.localcontext.update({ 'time': time,
'get_name':self.get_name, 'pool': self.pool,
}) self.context = context

def get_name(self, form):       
    crm_obj=pool.get('crm.lead')
    sale_obj=self.pool.get('hr.employee')
    for order in crm_obj.browse(cr, uid, id):
        namev=val.name
        print namev,"hhhhhhhhhhhhhhhhhhhhhhhhhhh"   
    print x 

            global name 'pool' is not defined

-------------------------------->if i do this i got this error (<type 'exceptions.nameerror'="">, NameError("global name 'pool' is not defined",), <traceback object="" at="" 0x7f070c2f0ea8="">)

Avatar
Discard
Best Answer

Hello my friend;

Hoping this may help you.

class lead_target(report_sxw.rml_parse):

def __init__(self, cr, uid, name, context):

super(lead_target, self).__init__(cr, uid, name, context)

self.localcontext.update({

'time': time,

'get_name':self.get_name, 'pool': self.pool,

'cr':cr,

'uid':1,

'ctxt':context,

})

def get_name(self, form, context=None):

if not context:

context = None

res_list=[]

crm_obj=self.pool.get('crm.lead')

sale_obj=self.pool.get('hr.employee')

obj_ids = crm_obj.search(self.cr, self.uid, [])

res = crm_obj.read(self.cr, self.uid, obj_ids, ['id', 'name'], context)

for r in res :

objs = {}

name = r['name']

res_list.append(objs)

print name,"hhhhhhhhhhhhhhhhhhhhhhhhhhh"

print x

return res_list

Best Regards.

Avatar
Discard
Best Answer

crm_obj=pool.get('crm.lead')

Re write as following

crm_obj = self.pool.get('crm.lead')
Avatar
Discard
Author

already i defind there

as Arif said: replace the occurance of 'pool' in crm_obj=pool.get('crm.lead') or any occurance of 'pool' by self.pool

Arif and Naresh are right. Instead of pool.get, you should use self.pool.get('your.object.name').

pool which you have defined in localcontext inside __init__ method, cannot be used directly. It can only be used in your report template (RML, Qweb).

friend, make us know if you have found the solution :)