Skip to Content
Menu
This question has been flagged
2 Replies
9921 Views
import time
import datetime
from report import report_sxw
#from tools import amount_to_text_en
import pooler
from tools import amount_to_text
#from tools.amount_to_text 
import amount_to_text_infrom tools.translate import _

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,        
        })
        self.context = context


def get_name(self, form):       
    crm_obj=self.pool.get('crm.lead')
    sale_obj=self.pool.get('hr.employee')
    for order in crm_obj.browse(cr, uid, ids, context=context):
        namev=val.name
    print namev,"print value"   
    if form['target_selection']=='daily':
        todaydate=datetime.date.today()
Avatar
Discard
Best Answer

You can update the object's pool attribute to report's localcontext

just like this:

self.localcontext.update({ 'time': time, 'get_name':self.get_name, 'pool': self.pool, })

and then use the pool.get('res.users').xxxooo in your report.

Avatar
Discard
Author

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 ---->    global name 'pool' is not defined
Best Answer

Hi!

You can browse the record from other model like this,

def get_name(self, form):       
    crm_obj=self.pool.get('crm.lead')
    sale_obj=self.pool.get('hr.employee')
    crm_ids = crm_obj.search(self.cr, self.uid, [])
    for order in crm_obj.browse(self.cr, self.uid, crm_ids):
        namev=val.name
    print namev,"print value"   
    if form['target_selection']=='daily':
        todaydate=datetime.date.today()

In report.py file we are not importing osv module so we have to write self.cr, self.uid instead of just cr,uid

Hope now it will work properly.

Thanks.

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 15
3137
1
Mar 15
4184
2
Mar 15
5245
0
Mar 15
2929
0
Mar 15
3045