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
11091 Widoki
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()
Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor

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
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 15
4143
1
mar 15
5054
2
mar 15
6269
0
mar 15
3828
0
mar 15
3838