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.

0

how to browse the record from other model

By
gpkarthick
on 5/3/13, 6:36 AM 2,052 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()
1
mrshelly
On 5/3/13, 7:01 AM

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.

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
gpkarthick
on 5/3/13, 7:17 AM
1

Keyur

--Keyur--
1165
| 4 4 8
Ahmedabad, India
--Keyur--

Odoo Expert

Keyur
On 6/25/13, 4:41 AM

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.

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, 6:36 AM
Seen: 2052 times
Last updated: 3/16/15, 8:10 AM