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.

1

global name 'pool' is not defined error

By
gpkarthick
on 5/3/13, 7:20 AM 3,448 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="">)

1

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
On 11/16/15, 4:25 AM

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.

1
arif
On 5/3/13, 7:23 AM

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

Re write as following

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

already i defind there

gpkarthick
on 5/3/13, 7:24 AM

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

Naresh Soni (nch)
on 5/3/13, 8:28 AM

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

Sudhir Arya (SA)
on 11/14/15, 7:48 AM

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

Sudhir Arya (SA)
on 11/14/15, 7:53 AM

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

Drees Far
on 11/17/15, 4:05 AM

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

0 follower(s)

Stats

Asked: 5/3/13, 7:20 AM
Seen: 3448 times
Last updated: 11/16/15, 4:25 AM